Remote connection for MySQL under Linux

Source: Internet
Author: User

Reprint: http://www.cnblogs.com/fnlingnzb-learner/p/5830661.html

If MySQL is installed and set up as per the previous method, it is a little easier to connect remotely. I will combine some articles on Baidu to analyze.

Local Computer ip:192.168.1.100
remote computer ip:192.168.1.244

  1. Connect the Linux system remotely to ensure that the Linux system is installed on the MySQL database. Log in to the database. Mysql-uroot-p (password).

  2. Create a user to connect remotely

    GRANT all privileges on * * to ' itoffice ' @ ' percent ' identified by ' Itoffice ' with GRANT OPTION;

    (The first itoffice represents the user name,% means that all computers can connect, you can set an IP address to run the connection, and the second itoffice represents a password).

  3. execute flush privileges; command takes effect immediately
  4. the user who queried the database (see the following indicating that the creation of the new user succeeded)

    SELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;

  5. Exit MySQL using the exit command

    Then open vim/etc/mysql/my.cnf.

    Will bind-address = 127.0.0.1

    Set to Bind-address = 0.0.0.0 (device address)

    Reboot (command below):

    /etc/init.d/mysql stop

    /etc/init.d/mysql start

  6. View Port Numbers

    Show global variables like ' port ';

  7. sets the Navicat connection.
  8. Click Connect Test to see that the following indicates success.

Note the problem:

1) I often display cannot connect to MySQL server when I enter Mysql-u root-p ... This error was later discovered to be that no MySQL was turned on. So before you do this, remember to check that MySQL has no open:

2) After the above connection, I use Navicat remote connection MySQL, found or not, tinker for a long time, only to find that because of the firewall problem, the firewall to the 3306 Port Shield. So to set up a firewall:

Set up firewall allow 3306 Port vi/etc/sysconfig/iptables add-A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT ( Note Before you add the-a rh-firewall-1-input-j reject–reject-with icmp-host-prohibited, it may cause the rule not to take effect) to restart the Firewall service iptables restart

Troubleshoot problems with MySQL not being able to connect remotely

1, MySQL port is correct
View port occupancy through NETSTAT-NTLP , typically 3306 for the lower end. The use of the tool to connect to MySQL is to use the port. For example, My admin\my Query browser\mysql front and so on.

2. Check whether the user rights are correct
The user table of the MySQL library has two records: host is localhost and% (for security,% can be replaced with IP you need to connect externally).

Remote connection to MySQL under Linux (go)

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.