当前位置:网站首页>Summary of remote connection of MySQL
Summary of remote connection of MySQL
2022-07-03 06:33:00 【Thousands of sails burn】
Preface
MySQL It is one of the most popular databases , It is also the preferred database for persistent storage of small and medium-sized enterprises .
Different from our daily study , in application ,MySQL Services will be attached to a server . If MySQL Deployed on a cloud server , thus , To manipulate the database, you need to connect to the server first , Then enter the database operation , Not very convenient .
therefore , Learning remote connections MySQL The method of is a required course when the database is on the server .
But for the sake of safety ,MySQL The remote connection of is not easy with one click , Especially in MySQL8.x version , We will introduce .
preparation
At this stage , Make sure you have entered the database service you want to access remotely , The usual interface is as follows :

Release remote host access
Generally speaking ,MySQL Only allow users to access on the local host . By inquiring user surface , You can also see the allowed host information :
select host,user from mysql.user

host Below the field localhost Represents that only local hosts are accepted .
therefore , Our work is very clear , Is to modify the access permission information , Enable the specified user to accept remote access . Generally speaking , We have two ways to achieve this effect .
The first one is : Change account permissions ( Suggest )
Since the remote host has no permission to connect , We can go through GRANT Statement to modify the permissions of the specified user .
GRANT The syntax of the statement is roughly :GRANT jurisdiction ON Database objects TO user .
Grant all permissions for all database operations to Any mainframe (’%’) Access to the root user , So any connected to the database root Users can access all information .
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ' Your password ' WITH GRANT OPTION;
Refresh the permissions :
flush privileges;
Query again , You can find that a new record will be added ,host Field % Means any host :

If you just want to grant A separate host Access right , be % It can be modified to the specified IP:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.28.71' IDENTIFIED BY
' Your password ' WITH GRANT OPTION;
The effect is similar to :

Refresh the permissions :
flush privileges;
The second kind : Modified table method
Use GRANT Statement is to add a new record directly , I personally suggest doing it in the above way .
however , We can also adopt direct modification user by root Of host Field contents , Use it directly UPDATE Statement modification table :
UPDATE mysql.user SET host = '%' WHERE user = 'root';
Refresh the permissions :
flush privileges;
The effect is as shown in the picture , Directly modifying host field value , Instead of adding .

To this step , Most of the time , We can use database tools such as :Web SQLyog、Navicat、Dbeaver Wait, connect to our remote database .
MySQL 8.x Points for attention
But please pay attention to , If your MySQL The version is 8.x Words , Due to the different ways of password encryption , The following prompt may appear when connecting :

therefore , We have to Change the encryption method To achieve remote connection , Use ALTER sentence :
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY ' Your password ';
Finally, don't forget to refresh permissions :
flush privileges;
OK, This is the end of the tutorial , If you have any problems , Welcome to comment in the comment area
Reference resources
边栏推荐
- 轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
- 2022年华东师范大学计科考研复试机试题-详细题解
- Mysql database
- About the difference between count (1), count (*), and count (column name)
- Simple password lock
- Push box games C #
- Svn branch management
- In depth analysis of kubernetes controller runtime
- Condition annotation in uni-app realizes cross segment compatibility, navigation jump and parameter transfer, component creation and use, and life cycle function
- Floating menu operation
猜你喜欢

Zhiniu stock project -- 05

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)

(翻译)异步编程:Async/Await在ASP.NET中的介绍
![[system design] proximity service](/img/4a/2e68536cbe385af1d1a591e674fbf0.png)
[system design] proximity service

【5G NR】UE注册流程

Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide

Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"

Selenium - by changing the window size, the width, height and length of different models will be different

“我为开源打榜狂”第一周榜单公布,160位开发者上榜

2022 cisp-pte (III) command execution
随机推荐
Zhiniu stock -- 03
SQL implementation merges multiple rows of records into one row
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
爬虫代码基础教学
Judge whether the date time exceeds 31 days
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
Zhiniu stock project -- 04
Know flex box
方差迭代公式推导
Chapter 8. MapReduce production experience
scroll-view指定滚动元素的起始位置
Zhiniu stock project -- 05
[system design] proximity service
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
JMeter linked database
Derivation of variance iteration formula
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Simple understanding of bubble sorting
Mysql
使用conda创建自己的深度学习环境