.comment-link {margin-left:.6em;}

IntTech

Friday, June 05, 2009

Creating MySQL users

Neither I or my MySQL using friends know of a nice easy way to create users in MySQL. But 3 commands are all that is needed in the basic case.
Log into mysql as administrator (mysql -u root -p) and enter the following:
CREATE USER 'userName'@'localhost' IDENTIFIED BY 'userPassword';
grant all on DBName.* to 'userName'@'localhost';
flush privileges;

There is a convention for web apps is that the database and user that accesses it have the same name. This is not required but is a general practice. In the above example userName would be the same as DBName.

Dropping a database: drop database DBName;
Notice that you do not put any type of quotes around the data base name DBName.

Bookmark and Share

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home


Google