标签:err span mys length general res cli 移除 更新
1. 下载并安装MySQL官方Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm yum -y install mysql-community-server
2. 启动mysql
systemctl status mysqld.service
systemctl start mysqld.service
3. 获取日志中的mysql密码
grep "password" /var/log/mysqld.log
4.修改mysql密码
# 进入mysql,使用上一步获取到的初始密码 mysql -uroot -p # 修改密码 alter user ‘root‘@‘localhost‘ identified by ‘new password‘; # 若密码设置过于简单违反密码设置规范,需要修改响应的规范 set global validate_password_policy=0; set global validate_password_length=1;
# 修改密码规则
use mysql;
set global validate_password_policy=low; # 设置low后,只会验证密码长度
set global validate_password_length=5; # 密码长度最小设置为5
5. 卸载Yum Repository,避免每次yum都要自动更新
yum -y remove mysql57-community-release-el7-10.noarch
6. 修改/etc/my.cnf配置文件
vim /etc/my.cnf # 配置文件中添加以下配置 [mysqld] character-set-server=utf8 collation-server=utf8_general_ci log-error=/var/log/mysqld.log [client] default-character-set=utf8 [mysql] default-character-set=utf8
7. 重启mysql数据库
systemctl restart mysqld
8. 创建数据库及数据库用户
# 创建数据库 create database db1 charset=utf8mb4; use db1; # 创建用户 create user ‘root‘@‘localhost‘ identified by ‘admin‘;
9. 权限设置
# 创建远程连接用户并赋予权限
grant all privileges on *.* to root@‘%‘ identified by ‘admin‘;
# 刷新权限
flush privileges;
# 移除权限 revoke all privileges on *.* from root@‘%‘; # 刷新权限 flush privileges;
标签:err span mys length general res cli 移除 更新
原文地址:https://www.cnblogs.com/weige007/p/12685419.html