Mysql allows remote connection.

Source: Internet
Author: User
The following articles mainly introduce the actual operation process for achieving MySQL remote connection. This article mainly introduces the specific operation steps for MySQL remote connection by using the relevant actual application code, the following describes the main content of the article, hoping to help you in this aspect. 1. Go to MySQL and create a new user root. The password is root: Type: grant

The following articles mainly introduce the actual operation process for achieving MySQL remote connection. This article mainly introduces the specific operation steps for MySQL remote connection by using the relevant actual application code, the following describes the main content of the article, hoping to help you in this aspect. 1. Go to MySQL and create a new user root. The password is root: Type: grant

The following articles mainly introduce the actual operation process for achieving MySQL remote connection. This article mainly introduces the specific operation steps for MySQL remote connection by using the relevant actual application code, the following describes the main content of the article, hoping to help you in this aspect.

1. Go to MySQL and create a new user root. The password is root. Format: grant permission on database name. Table name to user @ login host identified by "User Password ";

1. grant select, update, insert, delete on *. * to root@192.168.1.12 identified by "root ";

Original data table structure

1. MySQL> use MySQL;

2. Database changed

3. MySQL> select host, user, password from user;

4. + ----------- + ------ + --------------------------------------------- +

5. | host | user | password |

6. + ----------- + ------ + --------------------------------------------- +

7. | localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

8. + ----------- + ------ + --------------------------------------------- +

Result After executing the preceding statement

1. MySQL> use MySQL;

2. Database changed

3. MySQL> select host, user, password from user;

4. + -------------- + ------ + --------------------------------------------- +

5. | host | user | password |

6. + -------------- + ------ + --------------------------------------------- +

7. | localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

8. | 192.168.1.12 | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

9. + -------------- + ------ + --------------------------------------------- +

0.00 rows in set (sec) you can see that the root user you just created already exists 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 MySQL remote connection (authorization). Changing the host field value 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.

1. update user set host = '%' where user = 'root'; change the permission to all privileges 1. MySQL> use MySQL;

2. Database changed

3. MySQL> grant all privileges on *. * to root @ '%' identified by "root ";

4. Query OK, 0 rows affected (0.00 sec) 5. MySQL> select host, user, password from user;

6. + -------------- + ------ + --------------------------------------------- +

7. | host | user | password |

8. + -------------- + ------ + --------------------------------------------- +

9. | localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

10. | 192.168.1.12 | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

11. | % | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

12. + -------------- + ------ + --------------------------------------------- +

3 rows in set (0.00 sec) so that the machine can remotely access MySQL on the machine with the username root Password root.

3. Implement MySQL remote connection (change table method)

1. use MySQL;

2. update user set host = '%' where user = 'root'; in this way, you can access MySQL through the root user at the far end.

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.