Set remote access in mysql5.7 and remote access in mysql5.7

Source: Internet
Author: User

Set remote access in mysql5.7 and remote access in mysql5.7

In mysql5.7, setting remote access is not the same as setting up a user to grant permissions on the Internet. For example, the following example shows how to grant permissions to the user, which may be available in the previous version, but I have never been able to perform this operation on mysql. This is annoying for a long time !!! Project delay !!

I. The original remote access method

By default, Mysql cannot be accessed through a remote machine. The following configuration allows you to enable remote access.

On the MySQL Server:

Run the mysql command to enter the mysql command mode,

SQL code
  1. Mysql> use mysql;
  2. Mysql> grant all on *. * TO user @ '%' identified by '000000' with grant option;

# Allow any IP address (% above) to access the MySQL Server using the admin account and password (admin ).

# You must add an account like this to log on remotely. The root account cannot be remotely logged on. You can only log on locally.

Remote Access:
  1. Mysql-h172.21.5.29-uuser-p123456
  2. // 172.21.5.29 is the IP address of the MySQL Server, and the user is the remote access account set on 172.21.5.29.

In addition, you can simulate remote access on a machine, that is, open several more terminals to test whether remote access is allowed.

I found a problem. If you have finished executing the above command, you will be running localhost locally. Execute:
  1. Mysql-hlocalhost-uadmin-padmin

The result is failed.
The above % does not include localhost.

Therefore, you must add the following command:
Mysql> grant all on *. * TO admin @ 'localhost' identified by 'admin' with grant option;

2. Set remote access in mysql5.7

After setting it according to the above method, I found that mysql-h cannot be remotely accessed. I modified the/etc/my. cnf configuration file

# Comment out skip-networking
Bind-address = 0.0.0.0

However, it is useless!

I think it's almost time!

Later, I went straight to his configuration file: in the/etc/mysql folder.

Click my. cnf in the diagram:

#
# * IMPORTANT: Additional settings that can override those from this file!

# Configurations in other places can overwrite the configurations in this file
# The files must end with '. cnf', otherwise they'll be ignored.
#

! Includedir/etc/mysql/conf. d/
! Includedir/etc/mysql. conf. d/

I'm curious about the last two paths of the file. I went to see: conf. d /:

There is a configuration file in it. Open it and find that there is a [mysql], and there is nothing.

Let's look at another one:

There is also a configuration file, opened to find a surprise, there is a sentence here:

There is a feeling of seeing every day in an instant !!! You can see from its annotations that only local connections are allowed. The problem lies in this !!

Comment out bind-address: # bind-address =...

Restart the mysql service. remote connection:

  1. Mysql-h172.17.0.1-uuser-p

// My user name is: user

Finally, haha !!

It took two days !!! I'm convinced of mysql !!

 

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.