MySQL remote access permission, enabling remote connection

Source: Internet
Author: User

MySQL remote access permission, enabling remote connection
 
1. log on to the mysql database
Mysql-u root-p
View the user table www.2cto.com
Mysql> use mysql;
Database changed
Mysql> select host, user, password from user;
+ -------------- + ------ + --------------------------------------------- +
| Host | user | password |
+ -------------- + ------ + --------------------------------------------- +
| Localhost | root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
+ -------------- + ------ + --------------------------------------------- +
2 rows in set (0.00 sec)
 
You can see the created root user in the user table. The host field indicates the host to log on to. The value can be an IP address or a host name,
(1) If you want to log on with a local IP address, you can change the Host value to your own Ip address.
 
2. implement remote connection (authorization)
Changing the value of the host field to % indicates that you can log on to the mysql server as a root user on any client machine. We recommend that you set the value to % during development.
Update user set host = '%' where user = 'root ';
Change the permission to all privileges.
Mysql> use mysql;
Database changed
Mysql> grant all privileges on *. * to root @ '%' identified by "root ";
Query OK, 0 rows affected (0.00 sec) www.2cto.com
Mysql> select host, user, password from user;
+ -------------- + ------ + --------------------------------------------- +
| Host | user | password |
+ -------------- + ------ + --------------------------------------------- +
| Localhost | root | * a731aebfb621e354cd41baf207d884a609e81f5e |
| 192.168.1.1 | root | * a731aebfb621e354cd41baf207d884a609e81f5e |
| % | Root | * a731aebfb621e354cd41baf207d884a609e81f5e |
+ -------------- + ------ + --------------------------------------------- +
3 rows in SET (0.00 Sec)
In this way, the machine can remotely access MySQL on the machine with the username Root Password root.
3. remote connection (Table change)
Use MySQL;
Update user set host = '%' where user = 'root ';
In this way, you can access Mysql through the root user at the remote end.
 
 

Source: http://www.itzhe.org/Article/diannao/Database/201205/76780.html from IT Safety Net (www.itzhe.org)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.