Server MySQL allows remote connection

Source: Internet
Author: User

First login: Mysql-u root-h localhost-p

Use MySQL #打开mysql数据库

#将host设置为% means that any IP can be connected to MySQL, but you can also designate host as an IP

Update user set host= '% ' where user= ' root ' and host= ' localhost ';

Flush privileges; #刷新权限表 for the configuration to take effect

Then we can connect to our MySQL remotely.

3, if you want to close the remote connection, restore the default MySQL settings (only local connection), you can do the following steps:

Use MySQL #打开mysql数据库

#将host设置为localhost表示只能本地连接mysql

Update user set host= ' localhost ' where user= ' root ';

Flush privileges; #刷新权限表 for the configuration to take effect

Note: You can also add a user named Yuancheng, with a password of 123456, and a permission of% (indicating that any IP can connect) to a remote connection user. The command reference is as follows:

Grant all on * * to ' yuancheng ' @ ' percent ' identified by ' 123456 ';

Flush privileges;

Server MySQL allows 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.