Mysqlroot remote login solution _ MySQL

Source: Internet
Author: User
Mysqlroot remote login solution bitsCN.com

Today, when I used mysql workbench to connect to mysql on vmware, I was unable to connect. after reading the relevant information on the Internet, I collected some solutions:
1. authorization method: the root user of mysql can only log on locally by default, but cannot be remotely. if you connect remotely, you need to authorize:
Mysql> grant all privileges on *. * TO 'root' @ '%' with grant option;
Mysql> flush privileges;

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

2. change table method: similar to the authorization method, the result of the authorization method is to add a record to the user table of the database mysql. the host column value is '%', and the user column value is 'root ', see the following table:

+ ----------------------- + ------ +
| Host | user |
+ ----------------------- + ------ +
| % | Root |
| 127.0.0.1 | root |
| Localhost |
| Localhost | root |
| Localhost. localdomain |
| Localhost. localdomain | root |
+ ----------------------- + ------ +

3. open port 3306: more emphasis on root user authorization methods on the Internet,However, if only the root user is authorized and Port 3306 is not opened, the connection will still fail.
The method for enabling a port is as follows:
Open the/etc/sysconfig/iptables file(The file path varies with the operating system.) the file content is as follows:

# Firewall configuration written by system-config-firewall
# Manual customization of 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 -- dport 22-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
Add the content in bold Chinese to open port 3306 and restart iptables:
# Service iptables restrat

4. Another method is to modify the mysql configuration file my. the bind-address option in cnf. this option is not available in my configuration file. after this option is added, it does not work and I don't know why.

After repeated testsIt is required to authorize the root user and open port 3306.

BitsCN.com

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.