Open MySQL remote connection under Linux

Source: Internet
Author: User

Open MySQL remote connection under Linux

Based on security considerations The root account is generally only accessible locally, but it may be necessary to open the root remote access permission during the development process. Here are the basic steps:

1. Log in to MySQL, authorize remote access for root, and execute the following command:

Mysql> GRANT All privileges on * * to [email protected] '% ' identified by ' root ';

mysql> flush Privileges;

The "%" in the first sentence indicates that any host can be accessed remotely to the server. If you want to restrict access to only one machine, replace it with the appropriate IP, such as:

GRANT all privileges on * * to [e-mail protected] "172.168.193.25" identified by "root";

The second sentence reloads the permission data from the grant table in the MySQL database. Because MySQL puts permissions in the cache, it needs to be reloaded after the changes have been made.

2, modify/etc/mysql/my.cnf, need root user rights. Locate the file in:

    1. Bind-address = 127.0.0.1

Comment It out and save it.

3. Restart the MySQL server. Follow these few commands:

#/usr/bin/mysqladmin-u Root-p shutdown

#/usr/bin/mysqld_safe &

If Mysqladmin and Mysql_safe are not in the/usr/bin directory, they can be found through the Whereis command, for example:

# Whereis Mysqladmin

Mysqladmin:/usr/bin/mysqladmin/usr/share/man/man1/mysqladmin.1.gz

After performing the three steps above, the database can be connected via a remote machine.

done!

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.