Wednesday, 29 April 2009

How to create a new MySQL database and user from the command prompt

1. Start mysql.exe, the MySQL monitor:
C:\Program Files\mysql\mysql-5.0.77-win32\bin> mysql.exe -h localhost --user=root -p
2. Create the user and set the password:
mysql> CREATE USER theusername@localhost IDENTIFIED BY 'thepassword';
3. Make sure the new user appear in the user table:
mysql> SELECT * FROM mysql.user;
4. Create the database:
mysql> CREATE DATABASE yourdatabase;
5. Make sure your database was created:
SHOW DATABASES;
6. Grant all privileges for your new database to your user:
mysql> GRANT ALL ON yourdatabase.* to theusername@localhost;
7. Done. Now you got a new database and a new user with all privileges.

No comments:

Post a Comment