Navicate通过跳板机访问Mysql8.0实战记录

一、准备工作

1、已安装跳板机,示例IP:192.168.0.26,操作系统为ubuntu

2、已安装MySQL 8.0,本示例安装的是ubuntu系统支持的mysql 8.0版本(参考:https://bbs.huaweicloud.com/blogs/412913),示例IP:192.168.0.60

二、注意事项

1、mysql 8.0有多个配置文件,要找到正确的配置文件。

三、实现步骤

1、MySQL服务端授权配置

(1)指定可访问远程IP

vim /etc/mysql/mysql.conf.d/mysqld.cnf

更新配置

bind-address            = *
mysqlx-bind-address     = *

可以授权任何IP访问;也可以指定IP访问,如:192.168.0.26,当有多个IP时,中间用逗号隔开。

(2)访问授权配置

mysql -u root -p

输入password:

进入mysql> 控制台

按顺序执行以下授权指令:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

2、跳板机的操作

(1)安装Mysql-client

sudo apt-get install mysql-client

(2)通过客户端访问验证

mysql -h 192.168.0.60 -u root -p

回车,输入password:

显示以下内容则说明连接成功:

root@host:~# mysql -h 192.168.0.60 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.39-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

3、本地数据库连接工具测试,以Navicate为例:

配置数据库所在服务信息:

配置跳板机服务器信息,其中主机为外网可访问的IP或域名地址:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值