Teach you step by step to configure MySQL remote access

Teach you step by step to configure MySQL remote access

Preface

When using the MySQL database, sometimes the client needs to log in to the server's database directly remotely instead of sending the request to the database server. At this time, you need to configure the remote access permissions of MySQL. The specific configuration method is also very simple. You can find a lot of tutorials on how to configure remote login to the MySQL database by searching any search engine.

step

The steps introduced online are basically divided into two steps:

Modify the my.cnf configuration file

The mysql configuration file is usually in /etc/mysql/my.cnf. Open it to view its configuration. There is such a section:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

This bind-address is to bind the IP, which means that only the local machine is allowed to log in by default. In order to achieve remote login, this sentence obviously needs to be commented out. After modification, restart the mysql service.

Add User Permissions

As needed, set the corresponding permissions for the specified user and IP

mysql>GRANT ALL PRIVILEGES ON AB TO 'user'@'%'IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES

Here, all permissions on table B in database A are granted to the user from any host ('%') who logs in with password 'password'.

Or directly modify the user table in the MySQL database to meet the requirements.

The above is what you need to do in theory, but I did it and still couldn't connect. After a lot of trouble, I finally found out that the server provider had imposed additional restrictions on the opening of ports in order to ensure the security of the server. For example, Tencent server sets up a security group, which additionally restricts the open ports. By default, the MySQL port 3306 is prohibited from being opened. Therefore, you need to open the console and configure the permissions:

The rest are default, just add the second to last line. . .

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • The Ultimate Method for MySQL Remote Access Settings
  • Summary of how to set remote access permissions for MySQL database
  • How to set up remote access to mysql database
  • mysql set up a specified ip remote access connection instance
  • How to enable remote access rights for MySQL database (two methods)
  • Multiple methods of setting up remote access to the mysql database
  • Disable MySQL domain name resolution (to solve the problem of slow remote access to MySQL)
  • Two ways to solve the problem of remote access to mysql
  • Solution to MySQL not allowing remote access
  • Summary of methods for remote access to MySQL database

<<:  js to call the network camera and handle common errors

>>:  Detailed explanation of docker entrypoint file

Recommend

Python MySQL database table modification and query

Python connects to MySQL to modify and query data...

A brief discussion on the magic of parseInt() in JavaScript

cause The reason for writing this blog is that I ...

Detailed explanation of zabbix executing scripts or instructions on remote hosts

Scenario Requirements 1. We can use the script fu...

How to solve the high concurrency problem in MySQL database

Preface We all know that startups initially use m...

MySQL 8.0.11 Installation Tutorial under Windows

This article records the installation tutorial of...

Detailed explanation of this pointing problem in JavaScript

Preface The this pointer in JS has always been a ...

Mybatis implements SQL query interception and modification details

Preface One of the functions of an interceptor is...

Summary of several common ways to abbreviate javascript code

Table of contents Preface Arrow Functions Master ...

WeChat applet realizes linkage menu

Recently, in order to realize the course design, ...

Summary of HTML Hack Tags in IE Browser

Copy code The code is as follows: <!--[if !IE]...

How to place large images in a small space on a web page

Original source: www.bamagazine.com There are nar...

Example of how to install nginx to a specified directory

Due to company requirements, two nginx servers in...

MySQL green version setting code and 1067 error details

MySQL green version setting code, and 1067 error ...

Implementation of Docker cross-host network (manual)

1. Introduction to Macvlan Before the emergence o...