First, use the mysql program to connect to the server as the MySQL root user:
For Example:
or
shell>
mysql
-u root -p mysql
The following statements creates an user 'admin with password as 'admin'
% in the below syntax allow connections to MYSQL server from any host
mysql>
GRANT
ALL PRIVILEGES ON *.* TO 'admin'@'%'
->
IDENTIFIED
BY 'admin' WITH GRANT OPTION;
-> flush privileges;
The following statements creates an user 'admin with password as 'admin'
'localhost' in the below syntax allow connections to MYSQL server from localhost only.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost'
-> IDENTIFIED BY 'admin' WITH GRANT OPTION;
-> flush privileges;
To create Read-only User:
mysql>
use mydb
mysql>
GRANT
SELECT ON mydb.* TO 'roadmin'@'%'
->
IDENTIFIED
BY 'roadmin';
-> flush privileges;
flush privileges;
No comments:
Post a Comment