MySQL 在麒麟系统上部署使用 + DBeaver 远程连接 + SQL 数据导入完整流程

Lear 2025-11-29 10:38:17
Categories: Tags:

title: MySQL 在麒麟系统上部署使用 + DBeaver 远程连接 + SQL 数据导入完整流程

cover: /images/Logomini.jpg

copyright_author: Lear

copyright_url: www.lear.li

swiper_index: 10

top_group_index: 10

background: ‘#fff’

date: 2025-11-29 10:00:00

updated:

tags: [MySQL, DBeaver]

categories: [MySQL, DBeaver]

keywords:

description:

top:

top_img:

comments:

toc:

toc_number:

toc_style_simple:

copyright:

copyright_author_href:

copyright_info:

mathjax:

katex:

aplayer:

highlight_shrink:

aside:

ai:

MySQL 在麒麟系统上部署使用 + DBeaver 远程连接 + SQL 数据导入完整流程

适用于国产操作系统(如:麒麟 / 统信 / Ubuntu)和 MySQL 8.0+。包含远程配置、授权连接、SQL 导入、DBeaver连接配置等常见问题解决方案。

📦 环境准备

🔧 第一步:MySQL 安装与启动

sudo apt update

sudo apt install mysql-server

sudo systemctl start mysql

sudo systemctl enable mysql

🔐 第二步:设置 root 远程访问权限

1. 登录 MySQL

mysql -u root -p

2. 创建 root@% 用户或重设权限

DROP USER IF EXISTS ‘root‘@’%’;

CREATE USER ‘root‘@’%’ IDENTIFIED WITH mysql_native_password BY ‘你的密码’;

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@’%’ WITH GRANT OPTION;

FLUSH PRIVILEGES;

3. 确认结果

SELECT User, Host, plugin FROM mysql.user WHERE User=’root’;

输出应为:

User Host plugin
root localhost mysql_native_password
root % mysql_native_password

🌍 第三步:配置监听所有 IP

编辑配置文件:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

将以下配置项修改为:

bind-address = 0.0.0.0

保存并退出后重启 MySQL 服务:

sudo systemctl restart mysql

🧱 第四步:检查端口监听

sudo ss -tunlp | grep 3306

输出应包含:

LISTEN 0 … 0.0.0.0:3306 …

🧯 第五步:开放防火墙端口

如系统启用了 UFW 防火墙,执行:

sudo ufw allow 3306

sudo ufw reload

如使用 firewalld:

sudo firewall-cmd –permanent –add-port=3306/tcp

sudo firewall-cmd –reload

💾 第六步:导入 SQL 文件

1. 假设 SQL 文件路径为:~/桌面/all.sql

2. 创建数据库

CREATE DATABASE all DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

3. 导入命令

mysql -u root -p admindb < ~/桌面/admindb.sql

🧪 第七步:远程连接测试

在远程主机使用命令行连接:

mysql -h 192.168.1.211 -u root -p

如连接成功,输出如下:

Welcome to the MySQL monitor…

🖥️ 第八步:配置 DBeaver

配置项
服务器地址 192.168.10.888
端口 3306
数据库名 all(或实际库名)
用户名 root
密码 88888888

📌 常见错误汇总

报错信息 解决方案
Access denied for user ‘root‘@’192.168.X.X’ 检查用户权限,确认创建了 root@%,密码正确,且 plugin 为 mysql_native_password
Can’t connect to MySQL server on ‘192.168.X.X’ 检查端口监听,防火墙是否放行,bind-address 设置
No such file or directory 确认 SQL 文件路径是否正确,建议使用绝对路径

✅ 配置时间:2025-08-05 07:34:20

🎉 至此,你已完成 MySQL 远程访问部署 + SQL 数据导入 + DBeaver 连接 的全部操作!