Skip to content

MySQL

下载地址

阿里云镜像

bash
# MySQL Community Server
https://mirrors.aliyun.com/mysql/Downloads/MySQL-8.0/mysql-8.0.33-macos13-arm64.dmg
https://mirrors.aliyun.com/mysql/Downloads/MySQL-8.0/mysql-8.0.33-macos13-x86_64.dmg
https://mirrors.aliyun.com/mysql/Downloads/MySQL-8.0/mysql-8.0.33-winx64.zip
https://mirrors.aliyun.com/mysql/Downloads/MySQL-8.0/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
https://mirrors.aliyun.com/mysql/Downloads/MySQL-8.0/mysql-8.0.33-1.el8.x86_64.rpm-bundle.tar
https://mirrors.aliyun.com/mysql/Downloads/MySQL-8.0/mysql-8.0.33-1.el9.x86_64.rpm-bundle.tar
# MySQL WorkBench
https://mirrors.aliyun.com/mysql/Downloads/MySQLGUITools/mysql-workbench-community-8.0.33-macos-x86_64.dmg
https://mirrors.aliyun.com/mysql/Downloads/MySQLGUITools/mysql-workbench-community-8.0.33-winx64.msi

创建用户

bash
# 创建用户-外网
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
# 创建用户-内网
CREATE USER 'lms'@'192.168.%' IDENTIFIED BY 'root';

修改密码

bash
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
ALTER USER 'root'@'192.168.%' IDENTIFIED BY 'root';

如果提示密码不满足安全策略,那么可以尝试降低密码策略。

bash
# 查看当前密码策略
SHOW VARIABLES LIKE 'validate_password%';
# 降低密码策略
set global validate_password.length=4;
set global validate_password.special_char_count=0;
set global validate_password.policy =LOW;

授权

bash
# 授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
# 刷新权限
flush privileges;

数据库备份

bash
# 备份整个数据库
mysqldump -u username -p dbname > db.sql
# 备份单表
mysqldump -u username -p dbname tablename > table.sql