当前位置:网站首页>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==
边栏推荐
- js数组方法总结
- 如何用二分法搜索、查找旋转数组中是否含有某个(目标)值? leetcode 81.搜索旋转排序数组
- 问题10:注册页面的易用性测试?
- 身为程序员的我们如何卷死别人?破局重生。
- The general trend, another key industry related to Sino-US competition, has reached a critical moment
- 2021年12月电子学会图形化一级编程题解析含答案:下雨
- 2021年12月电子学会图形化二级编程题解析含答案:绘制多边形
- cmd 关闭端口
- 2021年12月电子学会图形化二级编程题解析含答案:消灭蝙蝠
- 2021年12月电子学会图形化四级编程题解析含答案:聪明的小猫
猜你喜欢

How to play deep paging with hundreds of millions of data?Compatible with MySQL + ES + MongoDB

语音识别新一轮竞争打响,自然对话会是下一个制高点吗?

2021年12月电子学会图形化四级编程题解析含答案:棕熊大战

劲爆!协程终于来了!线程即将是过去式

ECCV 2022 | 基于关系查询的时序动作检测方法

How much does Ark Survival Evolved cost?

如何将二维空间先验注入到ViT中? UMA&港理工&阿里提出SP-ViT,为视觉Transformer学习2D空间先验知识!...

证实了,百度没有快照了

js中的基础知识点 —— 事件

cmd 关闭端口
随机推荐
The general trend, another key industry related to Sino-US competition, has reached a critical moment
【网络结构】VGG
开源一夏 | 阿里云物联网平台之极速体验
0 code 4 steps to experience IoT devices on the cloud
兔起鹘落全端涵盖,Go lang1.18入门精炼教程,由白丁入鸿儒,全平台(Sublime 4)Go lang开发环境搭建EP00
web漏洞之远程命令/代码执行
2021年12月电子学会图形化四级编程题解析含答案:新冠疫苗接种系统
2021年12月电子学会图形化四级编程题解析含答案:聪明的小猫
2021年12月电子学会图形化四级编程题解析含答案:森林运动会
2021年12月电子学会图形化一级编程题解析含答案:放学
文件包含之伪协议的使用
NFT盲盒挖矿DAO智能合约dapp系统开发详情
Ark server open tool, server tutorial win
2021年12月电子学会图形化三级编程题解析含答案:跳高比赛
并发编程的核心问题
2022年镇海夏令营组合数学和数论班 —— 数学作业 1
基于牛顿方法在直流微电网潮流研究(Matlab代码实现)
问题5:发现缺陷怎么办?缺陷的类型有哪些?
深度学习——安装CUDA以及CUDNN实现tensorflow的GPU运行
MySQL性能优化的'4工具+10技巧'