Enable MySQL remote connection in Linux

Source: Internet
Author: User
Enable MySQL remote connection in Linux

For security reasons, the root account can only be accessed locally, but the root remote access permission may be required during development. The basic steps are as follows:

1. log on to mysql and grant remote access permissions to the root user. run the following command:

Mysql> grant all privileges on *. * TO root @ "%" identified by "root ";

Mysql> flush privileges;

In the first sentence, "%" indicates that any host can be remotely logged on to the server for access. If you want to restrict access to only one machine, replace it with the corresponding IP address, for example:

Grant all privileges on *. * TO root @ "172.16193.25" identified by "root ";

The second statement indicates that the permission data is reloaded from the grant table of the mysql database. Because MySQL puts all permissions in the cache, it needs to be reloaded after modification.

2. modify/etc/mysql/my. cnf with the root user permission. Find the file:

  1. Bind-address = 127.0.0.1

Comment it out and save it.

3. restart the MySQL server. Run the following commands:

#/Usr/bin/mysqladmin-u root-p shutdown

#/Usr/bin/mysqld_safe &

If mysqladmin and mysql_safe are not in the/usr/bin directory, you can run the whereis command to find them. for example:

# Whereis mysqladmin

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

After completing the preceding three steps, you can connect to the database through a remote machine.

Done!

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.