Setting MYSQL database privilages for user

To use MySQL database you need to give your user permission (privallages) to access and edit the database.
The example below give full privillages to user to edit and acces the database.
1. Log in to mysql with the user that have full permission .
[root@bakawali ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1408 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
2. To Grand All privillages to database user.
mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'database_user'@'localhost' IDENTIFIED BY 'user_password';
Query OK, 0 rows affected (0.07 sec)
3. To apply the changes execute this command
To activate the new permissions, enter the following command:
FLUSH PRIVILEGES;
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.05 sec)
4. To exit the mysql database
mysql> exit
Bye
[root@bakawali ~]#
NOTE: Below is the examle to grant specific privillages to the mysql database
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database_name.* TO 'database_user_name'@'localhost' IDENTIFIED BY 'user_password';
- Jason's blog
- Add new comment
- 1316 reads

Recent comments
15 hours 35 min ago
1 day 17 hours ago
2 days 21 hours ago
3 days 35 min ago
3 days 13 hours ago
4 days 18 hours ago
2 weeks 2 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago