当前位置:网站首页>Solve the problem of remote connection to MySQL under Linux in Windows
Solve the problem of remote connection to MySQL under Linux in Windows
2022-07-06 10:10:00 【Eric-x】
Preface
In actual development , We must connect to the database remotely , How is this set , Let's explore .
List of articles
Preparation conditions : One has MySQL Virtual machine of database , One has MySQL Database window
1、 problem
In use SQLyog or Navicat Configure remote connections in Mysql The following error messages are encountered when the database , This is because Mysql Configured... Caused by unsupported remote connection .
2、 Confirm the network
stay window Upper use ping ip Address Make sure the network is smooth
for example :ping 192.168.1.150
Turn on window Medium Telnet client
Open the control panel , Select small icon display , Click programs and functions , Then click enable or close window function 
take Telnet Client check 
3、 Turn off firewall or open port
Want to connect Linux Under the MySQL, You need to turn off the firewall or open the port , Choose one of them
The way 1: Turn off firewall
CentOS6 Instructions :service iptables stop
CentOS7 Appoint :systemctl stop firewalld.service
Set boot disable firewall :systemctl disable firewalld.service
The way 2: Open ports
// Check the open port number
firewall-cmd --list-all
// Set the open port number
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=3306/tcp --permanent
// service iptables restart
firewall-cmd --reload
4、 modify Linux Configuration below
1、 Turn on the virtual machine , Connect Linux Under the MySQL, Use as follows sql
use mysql;
select Host,User from user;
You can see root The current host configuration information of the user is localhost. It means using root Users can only connect to the database locally
modify Host For wildcard %
Host Column specifies the IP, such as user=root Host=192.168.1.1. This means that root Users can only pass through 192.168.1.1 Client access . user=root Host=localhost, It means that it can only be accessed through the local client . and % It's a wildcard , If Host=192.168.1.%, So that means as long as it's IP Address prefix is “192.168.1.” All clients of can connect . If Host=% , Express all IP All have connection permission .
Be careful : In a production environment, you can't save host Set to %, There will be security problems , Specific settings can be set according to the production environment IP Set it up
update user set host = '%' where user ='root';
Host Set up “%” Then you can allow remote access .
Host Remember to execute after modification flush privileges Make the configuration take effect immediately :
flush privileges;
5、 test
- If it is MySQL5.7 edition , You can use SQLyog perhaps Navicat Successfully connected to MySQL 了 .
- If it is MySQL8 edition , The following problems also occur when connecting :

Configuration new connection error : Wrong number 2058, The analysis is mysql Password encryption has changed
resolvent :Linux Next mysql -u root -p Log in to your mysql database , then Implement this SQL:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'abc123';
And then reconfigure SQLyog The connection of , The connection is successful , Fix up the work .
summary
In fact, the process is still very simple :
- First, check whether this machine can ping Through virtual machines IP Address
- Turn on window Medium Telnet Client services
- close Linux The firewall of ( Or open 3306 port )
- modify Linux Next MySQL Remote connection configuration ( Remember to refresh it immediately )
- Finally, if it is MySQL8.0 Reuse as above SQL Set up MySQL You can succeed ~
边栏推荐
- Cmooc Internet + education
- [NLP] bert4vec: a sentence vector generation tool based on pre training
- MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
- 美疾控中心:美国李斯特菌疫情暴发与冰激凌产品有关
- Sichuan cloud education and double teacher model
- Elk project monitoring platform deployment + deployment of detailed use (II)
- 嵌入式開發中的防禦性C語言編程
- cmooc互联网+教育
- Notes of Dr. Carolyn ROS é's social networking speech
- CANoe CAPL文件操作目录合集
猜你喜欢

Contest3145 - the 37th game of 2021 freshman individual training match_ C: Tour guide

软件测试工程师必备之软技能:结构化思维

华南技术栈CNN+Bilstm+Attention

如何让shell脚本变成可执行文件

51单片机进修的一些感悟

Can I learn PLC at the age of 33

Write your own CPU Chapter 10 - learning notes

51单片机进修的一些感悟

Hugo blog graphical writing tool -- QT practice

软件测试工程师必备之软技能:结构化思维
随机推荐
Preliminary introduction to C miscellaneous lecture document
Single chip microcomputer realizes modular programming: Thinking + example + system tutorial (the degree of practicality is appalling)
If a university wants to choose to study automation, what books can it read in advance?
西南大学:胡航-关于学习行为和学习效果分析
MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
16 医疗挂号系统_【预约下单】
CANoe CAPL文件操作目录合集
如何让shell脚本变成可执行文件
Redis集群方案应该怎么做?都有哪些方案?
通过bat脚本配置系统环境变量
History of object recognition
Mexican SQL manual injection vulnerability test (mongodb database) problem solution
vscode 常用的指令
Several errors encountered when installing opencv
Safety notes
C杂讲 动态链表操作 再讲
Routes and resources of AI
NLP routes and resources
Installation de la pagode et déploiement du projet flask
Control the operation of the test module through the panel in canoe (Advanced)