wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
yum install mysql80-community-release-el8-1.noarch.rpm
查看mysql源是否安装成功:
yum repolist enabled | grep "mysql.*-community.*"
yum module disable mysql
真正按安装mysql:
yum install mysql-community-server
启动mysql服务:
service mysqld start
查看mysql运行状态:
service mysqld status
查看mysql生成的随机密码:
grep 'temporary password' /var/log/mysqld.log
进入mysql服务:
mysql -u root -p [随机密码]
如果这个日志文件是空的,按以下步骤来进行:
find / -name my.cnf
查询my.cnf
文件路径[mysqld]
下面加上 skip-grant-tables
,表示跳过数据库权限验证,就可以不用密码进入mysql服务service mysqld restart
命令重启mysqld
服务mysql -uroot -p
,输入密码的时候直接回车即可切换到mysql数据库:
use mysql;
修改密码:
update user set password=password("123456") where user = 'root';
查看密码
SHOW VARIABLES LIKE 'validate_password%';
修改密码长度:
set global validate_password.length=1;
修改密码等级:
set global validate_password.policy=0;
1、先创建权限记录:
create user 'root'@'%' identified by '123456';
2、授权:
grant all privileges on *.* to 'root'@'%' with grant option;
mysql8.0默认采用caching_sha2_password的加密方式。sqlyog不支持这种加密方式。
1、修改密码过期
ALTER USER'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
2、重新修改密码
ALTER USER'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
3、刷新权限(不做可能无法生效)
FLUSH PRIVILEGES;