Turn on the local MySQL database remote connection

Source: Internet
Author: User

Do the site, to update the database frequently, contact with the database is certainly MySQL. Sometimes when building a station because the database and Web site in different IP, this time need to use the program for MySQL remote connection, and MySQL because of security factors, the default time user set is not remote connection, only local connection, this time you need to modify the settings. Here is a small part of the introduction of the Operation method.

Enter cmd command mode.

Mysql-h Localhost-u Mysql-p

Enter Password: ******

Connect to the database.

mysql> use MySQL; (This DB holds various configuration information for MySQL)

Database changed

Mysql> select Host,user from user; (View the user's permission condition)

+-------------+-------+

| Host | user |

+-------------+-------+

| localhost | |

| localhost | Root |

| localhost | |

| localhost | MySQL |

+-------------+-------+

6 rows in Set (0.02 sec)

As you can see, you can only access it as a host of localhost.

Mysql> Grant All privileges on * * to ' root ' @ '% ' identified by ' password ' with Grant option;

(% means all external machines, if a certain machine is specified, the% is changed to the corresponding machine name; "root" means the username to be used, and the password needs to be changed to the root password)

mysql> flush Privileges; (Run as a sentence to take effect, or restart MySQL)

Query OK, 0 rows affected (0.03 sec)

Mysql> select Host,user from user; (see user's permissions again)

+-------------+-------+

| Host | user |

+-------------+-------+

| % | MySQL |

| % | Root |

| localhost | |

| localhost | Root |

| localhost | |

| localhost | MySQL |

+-------------+-------+

Mysql>exit

Now try again: from the remote CMD to see if you can log in, can log in, the general code is also can be connected to.

Turn on the local MySQL database remote connection

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.