Add User privileges in MySQL

mysql> grant all privileges on absen.* to masbay@’localhost’ identified by ‘password’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -u masbay
ERROR 1045 (28000): Access denied for user ‘masbay’@’localhost’ (using password: NO)

C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -u masbay -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 94
Server version: 5.5.8-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> use hrad
ERROR 1044 (42000): Access denied for user ‘masbay’@’localhost’ to database ‘hrad’
mysql> use absen;
Database changed

ref: http://dev.mysql.com/doc/refman/5.7/en/grant-table-structure.html

it is working. masbay is not allowed to access any other db(s) except absen.

if you want to grant select only, and not to allow user access to do anything else, simple use :

grant select on absen.* to masbay@’localhost’ identified by ‘password’;

in php connection string, simply use ‘password’ as the password.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s