- yum仓库下载mysql
sudo yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
- yum安装mysql
sudo yum install mysql-community-server
- 启动mysql服务
sudo service mysqld start
- 检查mysql服务状态
sudo service mysqld status
- 查看初始化密码
sudo grep 'temporary password' /var/log/mysqld.log
- 修改密码安全级别
# mysql8修改密码校验方案前,需要先修改初始化密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '!!11qqAAzz';
# 查看当前密码安全级别
mysql> SHOW VARIABLES LIKE 'validate_password%';
# 修改密码校验方案等级
mysql> set global validate_password.policy=0;
# 修改密码校验长度未4位
mysql> set global validate_password.length=4;
# 这个时候可以和mysql8之前的密码设置方案一样了
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
- 配置mysql外部访问
## 云服务器要先检查安全组规则
# 切换到mysql库
mysql> use mysql;
# 查看用户对应允许访问的主机
mysql> select user,host from user;
# 修改root用户允许外部访问
mysql> update user set host = '%' where user ='root';
# 刷新权限
mysql>flush privileges;
- 导入mysql的test_db
test_db为mysql官方示例数据库,数据涵盖较全,适合测试sql,索引验证等;
参考地址:(https://github.com/datacharmer/test_db)
# 克隆test_db项目
git clone https://github.com/datacharmer/test_db.git
# 切换到项目目录下,导入employees库
test_db> mysql -uroot -pxxxx < employees.sql
网友评论