Solve the MySQL does not allow remote access method

Source: Internet
Author: User
Keywords Network programming Mysql tutorial
Tags access allow user change computer connect host log in login

Solution:

1. Table change method.

It may be your account does not allow remote login, only localhost. This time as long as the localhost that computer, log in mysql, change the "mysql" database "user" table in the "host" entry from the "localhost" renamed the "%"

mysql -u root -pvmwaremysql> use mysql;

mysql> update user set host = '%' where user = 'root';

mysql> select host, user from user;

2. Authorization Act

For example, if you want myuser to use mypassword to connect to the mysql server from any host.

GRANT ALL PRIVILEGES ON *. * TO 'myuser' @ '%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

If you want to allow user myuser to connect to the mysql server from a host whose ip is 192.168.1.6 and use mypassword as the password

GRANT ALL PRIVILEGES ON *. * TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

If you want to allow user myuser to connect to the mysql server's dk database from the host where ip is 192.168.1.6 and use mypassword as the password

GRANT ALL PRIVILEGES ON dk. * TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

I use the first method, the beginning not found, check on the Internet a little less implementation of a statement mysql> FLUSH RIVILEGES so that the changes take effect.

Another way, but I have not personally tried, looking for in the csdn.net, you can look at.

On the machine where mysql is installed:

1, d: mysqlbin> mysql-h localhost-u root / / This should be able to enter the MySQL server

2, mysql> GRANT ALL PRIVILEGES ON *. * TO 'root' @ '%' WITH GRANT OPTION / / give any host access to the data

3, mysql> FLUSH PRIVILEGES / / modify the entry into force

4, mysql> EXIT / / exit the MySQL server

So that you can log in as root on any other host!

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.