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

Solution to MySQL master-slave delay problem

Today we will look at why master-slave delay occu...

Comparative Analysis of UI Applications of Image Social Networking Sites (Figure)

In our life, work and study, social networks have ...

Web Design Tutorial (3): Design Steps and Thinking

<br />Previous tutorial: Web Design Tutorial...

MySQL's conceptual understanding of various locks

Optimistic Locking Optimistic locking is mostly i...

Gitlab practical tutorial uses git config for related configuration operations

This article introduces the content related to gi...

AsyncHooks asynchronous life cycle in Node8

Async Hooks is a new feature of Node8. It provide...

Detailed explanation of the seven data types in JavaScript

Table of contents Preface: Detailed introduction:...

Web page HTML code: production of scrolling text

In this section, the author describes the special...

Implementing a simple calculator with javascript

This article example shares the specific code of ...

Detailed tutorial on installing the jenkins container in a docker environment

Recommended Docker learning materials: https://ww...

JavaScript to achieve lottery effect

This article shares the specific code of JavaScri...

How to display small icons in the browser title bar of HTML webpage

Just like this effect, the method is also very si...

Detailed explanation of several error handling when Nginx fails to start

When using Nginx as a Web server, I encountered t...