下载mysql安装包
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装mysql 安装源:
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
在线安装mysql
yum -y install mysql-community-server
安装mysql出现Public key for mysql57-community-release-el7-11.noarch.rpm is not installed
可以使用以下命令即可
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
启动mysql服务
systemctl start mysqld
设置开机启动
systemctl enable mysqld
systemctl daemon-reload
修改root密码,mysql会生成一个临时密码,查看临时密码
vim /var/log/mysqld.log
记住初始密码,修改root密码
mysql -uroot -p
修改临时密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '0xh*sKIo)9JL';
查看validate-password属性
修改validate_password_length和validate_password_policy的值
set global validate_password_length=4;
set global validate_password_policy=0;
设置简单密码
set password=password("123456");
root 用户远程登录权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
刷新权限
flush privileges;