MySQL root user cannot log on remotely

Source: Internet
Author: User
Tags iptables firewall

Today, using MySQL Workbench to connect to MySQL on VMware, has been unable to connect, after consulting the relevant information on the Internet, collected a number of solutions:
1, Authorization law: MySQL root user by default only in the local landing, not remote, if remote connection, need authorization:

The code is as follows Copy Code
Mysql>grant all privileges in *.* to ' root ' @ '% ' with GRANT OPTION;
Mysql>flush privileges;

(' root ' @ '% ', specifies that the root user can connect to a database server on any computer, to specify a specific computer, to replace% with a specific IP)

2, the Change Table method: And the authorization law is similar, the result of the authorization law is to add a record in the database MySQL user table, the Host column value is '% ', the user column value is ' root ', as the following table:

The code is as follows Copy Code
+-----------------------+------+
| Host | user |
+-----------------------+------+
| %                              | Root |
| 127.0.0.1 | Root |
|        localhost | |
| localhost | Root |
|        Localhost.localdomain | |
| Localhost.localdomain | Root |
+-----------------------+------+

3, open 3306 ports: The Internet is more emphasis on the root user authorization method, but if only to the root authorization and not open 3306 ports, still cannot connect.
The open ports approach is as follows:
Opens the file/etc/sysconfig/iptables (the file path varies depending on the operating system) and the contents of the file are as follows:

/table>
  code is as follows copy code
# Firewall Configuration written by System-config-firewall
# Manual Customization to this file is not recommended.
*FILTER
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State--state established,related -j ACCEPT
-a input-p icmp-j ACCEPT
-a input-i lo-j ACCEPT
-a input-m state--state new-m tcp-p TCP--d Port 22-j ACCEPT
-a input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-a input-j REJECT--reject-w ITH icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT


Add bold text to open port 3306 and restart Iptables:
#service iptables Restrat

4, there is another way to change the MySQL profile my.cnf in the bind-address option, my profile does not have this option, plus, after no effect, do not know what the reason.

The above four places, after repeated trials, where the authorization root and open 3306 ports are necessary, indispensable.

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.