在 Debain 10 服务器上安装配置 MySQL 小记

This article was last updated days ago, some of the information may be outdated.

配置 MySQL 存储库

wget http://repo.mysql.com/mysql-apt-config_0.8.16-1_all.deb
sudo apt install ./mysql-apt-config_0.8.16-1_all.deb

按照提示安装即可

用 apt 安装 MySQL

sudo apt update
sudo apt install mysql-server

由于我是个人学习使用,不考虑安全性,也就没有使用 mysql_secure_installation 命令

启用 root 用户远程连接

use mysql;
select Host,User from mysql.user;

结果如下

mysql> select Host,User from mysql.user;
+-----------+------------------+
| Host      | User             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)

可以看到 root 用户只允许 localhost 进行连接
使用 SQL 语句将 localhost改为%

update mysql.user set `Host` = '%' where `Host` = 'localhost' and User = 'root';

结果如下

update mysql.user set `Host` = '%' where `Host` = 'localhost' and User = 'root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

再执行 flush privileges; 使改动生效
此时再使用 Navicat 测试连接,结果提示成功

Author: ZnS

Permalink: https://zns.moe/articles/Deploy-MySQL-on-Debian10/

文章默认使用 CC BY-NC-SA 4.0 协议进行许可,使用时请注意遵守协议。

Comments

Unable to load Disqus, please make sure your network can access.