/ mozey.co / blog

mysql create database

July 1, 2013

First create the new database

create database myDatabaseName;

Then create a user for the database

create user 'myUserName'@'localhost' identified by 'myPassword';

And grant all privileges on the database to the user

grant all on myDatabaseName.* to 'myUserName'@'localhost';

Or to create a read only user

grant select on myDatabaseName.* to 'myUserName'@'localhost';

To delete a database and its user execute

drop database myDatabaseName;

drop user myUserName;