赞
踩
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum -y install mysql80-community-release-el7-3.noarch.rpm
yum install -y mysql-community-server --nogpgcheck
systemctl start mysqld.service
systemctl enable mysqld.service
grep "password" /var/log/mysqld.log #查看初始密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
sudo mysql_secure_installation
会有多个步骤: (注意这里设置密码,默认密码复杂度是中,需要 大写字母,小写字母,数字)
Enter password for user root:
输入刚刚得到的密码
New password:
输入新的密码
Re-enter new password:
重复输入新的密码
Change the password for root ? ((Press y|Y for Yes, any other key for No)
是否想改变root的密码,输入Y,重复设置密码。
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No)
输入Y
Remove anonymous users? (Press y|Y for Yes, any other key for No)
删除匿名用户,输入Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No)
是否禁止远程登录,输入N(这个是允许远程登陆,但是设置好像不起效果)
Remove test database and access to it? (Press y|Y for Yes, any other key for No)
是否删除test数据库,输入Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No)
是否重新加载到权限表,输入Y
mysql -u root -p
输入刚刚设置的密码进入mysql
SHOW VARIABLES LIKE 'validate_password%'; #查看有哪些可用变量
SET GLOBAL validate_password.policy= 0; #密码复杂度设置为低 1为中 2为高
set global validate_password.length = 6; #设置密码最短长度
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码'; # 再次修改密码
create user root@"%" identified by "密码"; #新增允许远程root用户
grant all privileges on *.* to root@"%" with grant option; #为新增的用户赋权
navicat连接测试
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。