Skip to content

Create a mysql database and User

Create a mysql database and User

mysql> CREATE DATABASE database1;

For creating a new user with all privileges (use only for troubleshooting), at mysql prompt type:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

For creating a new user with fewer privileges (should work for most web applications) which can only use the database named “database1″, at mysql prompt type:

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';

One Comment

  1. shibu

    This also works …

    mysqladmin -u root -p password [your-password]

    and

    mysqladmin -u root -p create [databasename ]

    Posted on 31-Oct-09 at 4:07 am | Permalink

Post a Comment

You must be logged in to post a comment.