Home > Database > Mysql Tutorial > body text

How to remotely connect the mysql port and modify it

coldplay.xixi
Release: 2020-10-23 09:45:38
Original
3957 people have browsed it

How to modify the mysql remote connection port: first enter the directory of the mysql configuration file and edit the file; then modify the port number and allow remote binding, and keep it; then restart the mysql service; finally enable remote access. Can.

How to remotely connect the mysql port and modify it

More related free learning recommendations: mysql tutorial(video)

Mysql remote connection port and modification method:

1. Enter the directory of the mysql configuration file

cd /etc/mysql/mysql.conf.d/
Copy after login

How to remotely connect the mysql port and modify it

2. Edit the mysqld.cnf file

vi mysqld.cnf

3. Modify the port number and allow remote binding

How to remotely connect the mysql port and modify it

Change the value of bind-address to: 0.0.0.0 Or comment out this line

How to remotely connect the mysql port and modify it

4. Save after modification;

Note: When I started configuring, I set the file permissions to 777. But after restarting the service, the port has not changed!!!!!

When the permission of the file was finally changed to 644, the mysql service was restarted and the port was changed

5. Restart the mysql service

/etc/init.d/mysql restart
Copy after login

How to remotely connect the mysql port and modify it

6. Log in to mysql

using the command: mysql -u root -p

How to remotely connect the mysql port and modify it

7. Enter the command to view the port number:

show global variables like 'port';
Copy after login

How to remotely connect the mysql port and modify it

8. Enable remote access (add users allowed for remote access or allow remote access for existing users.)

Grant the sql account all permissions to access any database on any host (%). The SQL statement is as follows:

The code is as follows:

grant all privileges on *.* to '账户'@'%' identified by '密码' with grant option;
Copy after login

Refresh new:

flush privileges;
Copy after login

9. Finally restart the mysql service

The above is the detailed content of How to remotely connect the mysql port and modify it. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template