当前位置:网站首页>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==
边栏推荐
猜你喜欢
随机推荐
一个在浏览器中看到的透视Cell实现
一文搞懂$_POST和php://input的区别
FATFS | 中文显示 | 长文件名
苹果开发「AI 建筑师」GAUDI:根据文本生成超逼真 3D 场景!
How much does Ark Survival Evolved cost?
WMS软件国内主要供应商分析
在北极都可以穿短袖了,温度飙升至32.5℃
【周报】2022年7月31日
自定SvgIcon公用组件
实习路途:记录给我的第一个实习项目中的困惑
nodeJs--跨域
力扣1206. 设计跳表--SkipList跳表是怎么跳的?
身为售后工程师的我还是觉得软件测试香,转行成功定薪11.5K,特来分享下经验。
Phaser(二):小恐龙跑酷游戏
上亿数据怎么玩深度分页?兼容MySQL + ES + MongoDB
【指针内功修炼】函数指针 + 函数指针数组 + 回调函数(二)
AWS中国区SDN Connector
接口测试主要测试什么?
DC-DC 2C(40W/30W) JD6606SX2退功率应用
新版本MaxCompute 的SQL支持 UDF 分区裁剪的逻辑是怎样的?









