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

Detailed explanation of MySQL redo log (redo log) and rollback log (undo logo)

Preface: The previous article described several c...

How to lock a virtual console session on Linux

When you are working on a shared system, you prob...

Vue3 implements Message component example

Table of contents Component Design Defining the f...

Detailed explanation of CSS elastic box flex-grow, flex-shrink, flex-basis

The functions of the three attributes flex-grow, ...

Summary of events that browsers can register

Html event list General Events: onClick HTML: Mous...

Implementation steps for docker-compose to deploy etcd cluster

Table of contents Write docker-compose.yml Run do...

A set of code based on Vue-cli supports multiple projects

Table of contents Application Scenario Ideas Proj...

CSS3 mobile vw+rem method to achieve responsive layout without relying on JS

1. Introduction (1) Introduction to vw/vh Before ...

Solution to the ineffectiveness of flex layout width in css3

Two-column layout is often used in projects. Ther...

Detailed explanation of the execution order of JavaScript Alert function

Table of contents question analyze solve Replace ...

Vue+Element UI realizes the encapsulation of drop-down menu

This article example shares the specific code of ...