下载MySQL8
复制链接
[root@localhost /]# wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
[root@localhost /]# yum -y localinstall mysql80-community-release-el7-2.noarch.rpm
[root@localhost /]# yum -y install mysql-community-server
安装完成后启动MySQL服务
[root@localhost /]# systemctl start mysqld
设置开机启动
[root@localhost /]# systemctl enable mysqld
[root@localhost /]# systemctl daemon-reload
获取MySQL初始密码
[root@localhost /]# cat /var/log/mysqld.log
2019-04-11T13:01:02.341577Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server in progress as process 7639
2019-04-11T13:01:04.351182Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: .IjaR)gfD3tj
2019-04-11T13:01:05.195421Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server has completed
2019-04-11T13:01:07.376550Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.15) starting as process 7687
2019-04-11T13:01:07.799335Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-04-11T13:01:07.829999Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.15' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
2019-04-11T13:01:07.926422Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
MySQL初始密码为:.IjaR)gfD3tj
登录MySQL
[root@localhost /]# mysql -u root -p
Enter password:
输入初始密码登录
修改登录密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'XXXXX';
Query OK, 0 rows affected (0.02 sec)
mysql>
XXXXX为设置的密码;