Sunday, 17 April 2016

How to give permission to any host for root user ?


Setting permission to any host on Windows
Run commands in the Server machine : 
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Database changed

mysql> GRANT ALL ON *.* to root@'10.239.199.57' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)
Permission of root is given to 10.239.199.57

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Setting permission to any host on Linux
You’ll need to update the mysql user table to allow access from any remote host, using the % wildcard. 

Step 1. Open the command line MySQL client on the server using the root account.
Set the MySQL environment and connect MySQL by root
$ mysql -u root -proot

Step 2. Run the commands to see what the root user host is set to already
> use mysql;
> select host, user from user;

Step 3. Update the localhost host to use the wildcard
> update user set host='%' where user='root' and host='localhost';

Step 4. Reload the privilege tables
> flush privileges;


In Step 3. instead of updating existing row in mysql table, you can insert a new row with host = % and user = root
Like
insert into user values('%','root','','Y','Y','Y','Y','Y','Y ','Y','Y ','Y ','Y','Y','Y','Y','Y','Y ','Y','Y','Y','Y ','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0)
flush privileges;


No comments:

Post a Comment

Note: only a member of this blog may post a comment.