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:
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 |
/table>
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.