当前位置:网站首页>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 ~
边栏推荐
- 四川云教和双师模式
- 15 医疗挂号系统_【预约挂号】
- Tianmu MVC audit II
- What you have to know about network IO model
- MySQL实战优化高手03 用一次数据更新流程,初步了解InnoDB存储引擎的架构设计
- AI的路线和资源
- [NLP] bert4vec: a sentence vector generation tool based on pre training
- A necessary soft skill for Software Test Engineers: structured thinking
- flask运维脚本(长时间运行)
- 寶塔的安裝和flask項目部署
猜你喜欢
How to make shell script executable
Preliminary introduction to C miscellaneous lecture document
PR 2021 quick start tutorial, first understanding the Premiere Pro working interface
再有人问你数据库缓存一致性的问题,直接把这篇文章发给他
颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
Some thoughts on the study of 51 single chip microcomputer
[after reading the series] how to realize app automation without programming (automatically start Kwai APP)
宝塔的安装和flask项目部署
CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
随机推荐
Preliminary introduction to C miscellaneous lecture document
CANoe不能自动识别串口号?那就封装个DLL让它必须行
Compress decompress
通过bat脚本配置系统环境变量
Cmooc Internet + education
Notes of Dr. Carolyn ROS é's social networking speech
MySQL combat optimization expert 03 uses a data update process to preliminarily understand the architecture design of InnoDB storage engine
Tianmu MVC audit II
max-flow min-cut
[NLP] bert4vec: a sentence vector generation tool based on pre training
MySQL combat optimization expert 09 production experience: how to deploy a monitoring system for a database in a production environment?
If someone asks you about the consistency of database cache, send this article directly to him
Upload vulnerability
VH6501学习系列文章
A necessary soft skill for Software Test Engineers: structured thinking
NLP路线和资源
Why is 51+ assembly in college SCM class? Why not come directly to STM32
MySQL ERROR 1040: Too many connections
How can I take a shortcut to learn C language in college
flask运维脚本(长时间运行)