Command line instructions to create a database in MySQL

$ mysql -u ”adminusername” -p

  1. mysql> CREATE DATABASE ”databasename”;
  2. mysql>
    grant all privileges on db_name.* to 'db_user'@'localhost' identified by 'db_password';
  4. mysql> EXIT

Report this snippet  


RSS Icon Subscribe to comments

Posted By: stevewa on July 9, 2010
on Ubunutu 10, this would not work when i removed the 2 single quotes around database name, then it worked.

just replace the databasename with the actual name of the databse you want to create… and replace username with your real username… and replace hostname with the name of your ubuntu server, usually “localhost” will work as the name of the host… and replace password with the ubunutu password for the username you typed before…

so on ubuntu:

mysql> CREATE DATABASE databsename ; mysql> GRANT ALL PRIVILEGES ON databasename.* TO ‘username’@’hostname’ IDENTIFIED BY ‘password’ ; mysql> FLUSH PRIVILEGES ; mysql> exit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s