当前位置:网站首页>How Navicat connects to MySQL on a remote server
How Navicat connects to MySQL on a remote server
2022-08-03 15:32:00 【Lovely hair】
本文已参与「新人创作礼」活动,一起开启掘金创作之路.
前言:
==Operating environment and tools==
Navicat for Mysql
One Tencent Cloud lightweight server(Centos 7)
Mysql 8.0.24(installed on the remote server)
Xshell7(连接操作远程服务器)
一、修改mysqlremote authorization login settings
1、Log in to the database of the remote server(使用Xshell)
mysql -uroot -p ## 以root登录数据库
复制代码
输入root的登录密码,After success, you will see the following information:
2、查看mysqlThe current default port for the service
use mysql; ## 选择mysql数据库
select user,host from user; ## View user access ports
复制代码
==说明:rootThe user default islocalhost,Note that only local login is allowedmysql服务.And we're going to take it remotelyroot用户连接数据库,就必须修改host的值,改为**'%'**:允许任何ip访问.==
3.修改host允许任何ip访问
Go ahead and enter the following commands in the command palette:
update user set host = '%' where user = 'root';
复制代码
Seeing the above information indicates that the modification is successful!
Then use the previous command again:
select user,host from user; ## View user access ports
复制代码
会看到:root用户的host已经修改为'%'!
==注意:修改完成后 Also need to refresh the service configuration,不然修改不会生效,并且第4step will fail.==
Then type in the command panel:
mysql> FLUSH PRIVILEGES; ## Refresh service configuration items
复制代码
显示Query OK,表示刷新完成.Now we can configure the user permissions we want to log in remotely.
4.授权root用户进行远程登录
输入命令:
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root_pwd'; ## 授权root远程登录 后面的root_pwdRepresents the login password
复制代码
输入完之后,看到Query OK,说明执行成功!
==说明:This command can authorize any mysql数据库userThe users in the table access the database by remote login,本例中以'root'作为举例,To authorize other users,只需修改'root'The value of the specified user can be used,'root_pwd'为'root'User's corresponding login password,It can be modified to the login password of the user you want to authorize.==
5.启动本地Navicat连接
打开Navicat客户端,新建mysql连接
输入相关信息:
If it shows that the connection is successful,那么恭喜你,The database can be operated remotely
==如果显示2003错误,无法连接上数据库,Please continue to see the operation below==
二、Solve the problem of unable to connect(2003)
1、First make sure that the firewall is allowed3306端口
2、Make sure fire prevention is activated
==未启动==
[[email protected] ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
FirewallD is not running
[[email protected] ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead) #Indicates that the fire resistance is not activated
Docs: man:firewalld(1)
复制代码
==已启动==
[[email protected] ~]# systemctl start firewalld
[[email protected] ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2021-03-07 20:57:40 CST; 9s ago #active (running)Indicates that the firewall is activated
Docs: man:firewalld(1)
Main PID: 29918 (firewalld)
CGroup: /system.slice/firewalld.service
└─29918 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
复制代码
3、放通防火墙
[[email protected] ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
复制代码
4、Re-add firewall rules
[[email protected] ~]# firewall-cmd --permanent --add-port=3305/tcp
success
[[email protected] ~]# firewall-cmd --reload
success
复制代码
==然后继续使用Navicatto connect==
边栏推荐
- 6000 字+,帮你搞懂互联网架构演变历程!
- 2021年12月电子学会图形化三级编程题解析含答案:分身术
- PHP高级面试题 - 第二天
- 程序员面试必备PHP基础面试题 – 第十九天
- How to use binary search and find whether the rotation in the array contains a (target) value?Rotate the sorted array leetcode 81. Search
- 南京一研究所回应招聘硕士保安:负责安全生产等,48人选1
- Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。
- 【周报】2022年7月24日
- 高压直流输电(HVDC)的最优潮流(OPF)(Matlab代码实现)
- JS handwritten call apply bind (detailed) (interview)
猜你喜欢
How to play deep paging with hundreds of millions of data?Compatible with MySQL + ES + MongoDB
leetcode:899. 有序队列【思维题】
基于牛顿方法在直流微电网潮流研究(Matlab代码实现)
Detailed explanation of cloud hard disk EVS and how to use and avoid pits [HUAWEI CLOUD is simple and far]
2021年12月电子学会图形化三级编程题解析含答案:数星星
js数组方法总结
STM32H743VIT6配置ADC为1M采样率
2021年12月电子学会图形化二级编程题解析含答案:消灭蝙蝠
49 万奖金等你来拿!第四届实时计算 Flink 挑战赛启动,Beyond Stream Processing!
Ark server opening tutorial win
随机推荐
【周报】2022年7月31日
sql注入之盲注(纯原创)
devops-2:Jenkins的使用及Pipeline语法讲解
高等数学(第七版)同济大学 习题4-1 个人解答
MATLAB gcf图窗保存图像,黑色背景/透明背景
在北极都可以穿短袖了,温度飙升至32.5℃
LyScript 验证PE程序开启的保护
Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。
【指针内功修炼】函数指针 + 函数指针数组 + 回调函数(二)
gocron定时任务管理系统的安装与运行
PHP中高级面试题 – 第一天
js中的基础知识点 —— 事件
自己悦表存心
分布式系统与微服务的区别
跨桌面端之组件化实践
Ark server open tool, server tutorial win
PWA 应用 Service Worker 缓存的一些可选策略和使用场景
【重构map】【重构filter】【重构Some】【重构reduce方法】【重构flat函数】
ruoyi若依框架@DataScope注解使用以及碰到的一些问题
未来无法预料