centos7.4下yum方式安装mysql8.0

安装环境为centos7.4
首先下载yum安装的镜像

wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安装

rpm -Uvh mysql80-community-release-el7-1.noarch.rpm 
yum install -y mysql-community-server

开启服务

service mysqld start

找到初始密码

grep 'temporary password' /var/log/mysqld.log
2018-08-15T06:13:14.412800Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: HhNLwoTU/01q

最后面这个字符串就是初始密码

mysql -uroot -p

输入上面那个初始密码

修改密码,这里注意一下,密码强度是有要求的,这也是MYSQL8的特性

mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
mysql>use mysql;

修改登录IP限制,不修改就只能本地登录

mysql>update user set host = '%' where user = 'root';

重新刷新一下,因为有的时候用远程工具连接会有问题

mysql>ALTER USER 'root'@'%' IDENTIFIED BY 'MyNewPass4!' PASSWORD EXPIRE NEVER;
mysql>ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'MyNewPass4!'; 

好了,用数据库的远程工具连接上可以用了

数据目录:/usr/lib/mysql
配置文件:/etc/my.cnf
日志:/var/log/mysqld.log
PID文件:/var/run/mysqld
sock:/var/lib/mysql/mysql.sock

你可能感兴趣的:(mysql)