centos7上安装mysql8.0
1.下载并安装MySQL
wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum -y install mysql80-community-release-el7-3.noarch.rpm
yum -y install mysql-community-server
2.启动
启动MySQL服务:
systemctl start mysqld.service
查看MySQL服务:
systemctl status mysqld.service
查看MySQL是不是开机自启,可以执行命令查看开机自启列表
systemctl list-unit-files|grep enabled
3. 登录
找出root用户的密码
grep "password" /var/log/mysqld.log
2020-10-28T04:18:27.997156Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ,p;t<Px4Hyws
其中 ",p;t<Px4Hyws"即为初始密码
mysql -uroot -p
输入密码后
更改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'abcdQWER1234!!';
设置允许远程连接, 此处与5.x版本不同, 需要先创建后授权
创建用户:
CREATE USER 'admin'@'%' IDENTIFIED BY 'abcdQWER1234!!';
允许远程连接:
GRANT ALL ON *.* TO 'admin'@'%';
客户端连接报错, 修改密码策略
ALTER USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'abcdQWER1234!!';
测试连接成功!!