Troubleshoot problems with MySQL on a Linux server that cannot be connected remotely

Source: Internet
Author: User
Tags iptables mysql command line

today, I installed MySQL on the server in the lab and found that the remote computer couldn't connect to the MySQL server. The server operating system is Ubuntu 14.04. So on the Internet to check some information, toss a half-day after finally fix, the following is the specific steps.

1) After installing MySQL, modify the following files.

sudo vim/etc/mysql/my.cnf "If you are not very good with the VI editor, you can use SSH login, after the file removal manual changes, upload to the server to overwrite the file can be"

Find bind-address = 127.0.0.1, change the binding address to the address of your server "is the IP of your server machine"

2) then start the MySQL service, or restart the service if the service is started

Sudo/etc/init.d/mysql start (script start) or service mysqld start (command start)

Sudo/etc/init.d/mysql Restart (script restart) or service mysqld restart (command restart)


3) Open MySQL
sudo mysql-uroot-p
Enter the password, enter the MySQL command line, and execute the following command on the MySQL command line
Grant all privileges on * * to [email protected] '% ' identified by ' Onepassword ';
Perform
Use Information_schema "or other DB instance"

SELECT * from User_privileges;


4) If the query has the following result: ' Root ' @ '% ', it means that MySQL has been authorized to connect remotely.
Exit the MySQL command line and execute it in the terminal
Iptables-a input-p TCP--dport 3306-j ACCEPT
Add 3306 ports to the iptables.


5) Restart the MySQL service by executing the following command last

Sudo/etc/init.d/mysql Restart (script restart) or service mysqld restart (command restart)


then the other computer can be remotely connected to the server on the MYSLQ, although the problem is not, it is not the first encounter, but each time it takes a lot of time to solve, make a small record, in case you encounter similar problems in the future, but also from the beginning.

Troubleshoot problems with MySQL on a Linux server that cannot be connected remotely

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.