MySQL database on remote access server, root remote connection not found

Source: Internet
Author: User
Tags iptables

Remote access to the MySQL database on the server, the discovery root remote connection is not on, prompt error: "1045-access denied for user [email protected]"

The workaround is as follows, execute the command:

mysql> use MySQL;

Mysql> selecthost,user from user;

See if the root user is allowed to log on locally (localhost) only, this is the case.

Yes, it is necessary to modify its host to%, which means that any IP address can be logged in.

GRANT all privileges on * * to ' root ' @ '% ' identified by ' root ' with GRANT OPTION;

mysql> flush Privileges;

Flush the cache. After you modify a user record by using the UPDATE statement, the FLUSH statement is required to tell the server to overload the authorization table.

Not successful yet?

1. Start the mysql cmd command

2. Using the "Use MySQL" command, select the database you want to use, modify the basic information of the remote connection, save it in the MySQL database, and use the MySQL database.

3. Use "Grant all privileges on *. * to ' root ' @ '% ' identified by ' root ' with Grant OPTION;" command to change the settings for a remote connection.

4. Use "Flush privileges;" command to refresh the permission that you just modified to take effect.

5. Use "select Host,user from User;" See if the changes were successful.

6. You will not be able to access it after that. Then went to the server local access to see a bit.

Above, the last line of% root password changed to be the same as the first one.

You can then access it.

The other connection is not a problem:

Firewall Port adding ports to listen on
/sbin/iptables-i input-p TCP--dport 3306-j ACCEPT

Save Settings
/etc/init.d/iptables Save

View status
/etc/init.d/iptables status

Temporarily shutting down the firewall server
Iptables stop

Turn on Firewall service
Service Iptables Start

Boot no longer starts Firewall service
Chkconfig iptables off

MySQL database on remote access server, root remote connection not found

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.