How to enable MySQL remote connection in Linux server

How to enable MySQL remote connection in Linux server

Preface

Learn MySQL to reorganize previous non-MK records

describe

If it is not enabled, an error message will be displayed when connecting to the database: 2003-can't connect to MYSQL

Methods/Steps

•first step

Remotely connect to the Linux system and make sure the MySQL database has been installed on the Linux system. Log in to the database.

mysql -u$user -p $pwd

•Step 2

Create a user for remote connection

GRANT ALL PRIVILEGES ON *.* TO '$username'@'%' IDENTIFIED BY '$password' WITH GRANT OPTION;

$username indicates the user name, % indicates that all computers can connect, or you can set a certain IP address to run the connection, $password indicates the password

•Step 3

Execute the flush privileges; command to take effect immediately.

FLUSH PRIVILEGES;

• Step 4

Query the database user

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

•Step 5

Then open vim /etc/mysql/my.cnf

Set bind-address = 127.0.0.1

Set to bind-address = 0.0.0.0 (device address)

Restart

/etc/init.d/mysql restart

• Check the MYsql global port (the default is 3306)
#Check the port number

show global variables like 'port';

So far, the configuration has been completed

You may also be interested in:
  • How to install MySQL and enable remote connection on cloud server Ubuntu_Server_16.04.1
  • How to modify mysql to allow remote connections
  • How to configure MySQL on Ubuntu 16.04 server and enable remote connection
  • How to enable remote connection (multiple backups) for MySQL database
  • mysql opens remote connection (mysql opens remote access)
  • How to enable remote connection to MySQL database
  • Detailed explanation of MySQL remote connection permission

<<:  How to use shell scripts in node

>>:  MySQL installation tutorial under Centos7

Recommend

Tutorial on how to install htop on CentOS 8

If you are looking to monitor your system interac...

Docker deploys Macvlan to achieve cross-host network communication

Basic concepts: Macvlan working principle: Macvla...

js to achieve simple image drag effect

This article shares the specific code of js to ac...

BUG of odd width and height in IE6

As shown in the figure: But when viewed under IE6...

How to hide the version number and web page cache time in Nginx

Nginx optimization---hiding version number and we...

How to create an index on a join table in MySQL

This article introduces how to create an index on...

After reading the introduction of CSS box model, you will not be confused

The property names often heard in web design: con...

MySQL Installer 8.0.21 installation tutorial with pictures and text

1. Reason I just needed to reinstall MySQL on a n...

Learn Vue middleware pipeline in one article

Often when building a SPA, you will need to prote...

Detailed explanation of custom configuration of docker official mysql image

In order to save installation time, I used the of...

Detailed explanation of the 4 codes that turn the website black, white and gray

The 2008.5.12 Wenchuan earthquake in Sichuan took...

Zen HTML Elements Friends who use zen coding can collect it

html ¶ <html></html> html:xml ¶ <h...

Modify the boot time of grub in ubuntu

The online search to modify the grub startup time...