1. 配置源
$ rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
2. 安装 MySQL 8 Community Server
$ sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo $ yum --enablerepo=mysql80-community install mysql-community-server
3. 启动
$ service mysqld start
4. 修改密码
$ grep "A temporary password" /var/log/mysqld.log
修改密码策略
$ mysql> -u root -p
$ mysql> set global validate_password.policy=0;
$ mysql> set global validate_password.length=4;
修改root临时密码
$ mysql_secure_installation # Enter password for user root: 临时密码 # New password: abc@123 # Re-enter new password: abc@123 # Remove anonymous users? y # Disallow root login remotely? y # Remove test database and access to it? y # Reload privilege tables now? y
5. 设置开机启动
$ chkconfig mysqld on
6. 添加账号并设置远程访问
$ mysql -u root -p # Enter password: abc@123 mysql> use mysql; mysql> create user 'sa'@'%' identified by 'abc@123'; mysql> GRANT ALL ON *.* TO 'sa'@'%' WITH GRANT OPTION; mysql> flush privileges;
7. 重启
$ service mysqld restart