Babar Haq

Wednesday, March 08, 2006


A lot of open source web based applications use mysql as a backend database. Almsot all of them require to create a mysql database and a mysql user who has full access to the database. Following is a quick tutorial on doing all that. This assumes that the db and application are on the same machine.

1) Connect to mysql as root user and create database
#mysqladmin -h localhost -u root -ppassword create databasename
Replace password by mysql root users password. Replace the databasename with the name you want to give your database.

2) Add a mysql user

Connect to mysql as root user
#mysql -h localhost -u root -ppassword
Replace password by mysql root users password.

mysql> USE mysql;
Switch to mysql database which holds the user information.

mysql> INSERT INTO user (Host, User, Password, Select_priv) VALUES ('localhost', 'username', password('password'), 'Y');
This adds the desired user name and allow him to connect from localhost. Replace the username and password in italic to the actual user name and password you want to assign.

databasename.* TO username;
Give full access on databasename to username.

Required everytime GRANT command is used.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home