启动mysql
systemctl start mysqld
# 查看网络端口
netstat -tulpn
# 查看mysql当前状态
systemctl status mysqld
设置mysql开机启动
systemctl enable mysqld
日志查看密码
grep "password" /var/log/mysqld.log
命令进入数据库:
mysql -uroot -p
设置初始密码
set password for root@localhost = "root";
或者
alter user 'root'@'localhost' identified with mysql_native_password by '52alwWQIst!sas';
修改权限
查看root登录权限
select host,user from user;
update user set host = '%' where user = 'root';
让刚才修改的配置立即生效
flush privileges;
# 添加放行3306端口
firewall-cmd --zone=public --permanent --add-port=3306/tcp
# 将防火墙配置重载
firewall-cmd --reload
# MySQL 8.0 调整密码验证规则:
set global validate_password.policy=low;
set global validate_password.length=1;