centos7安装mysql8

centos7 64 bit安装mysql8。

下载

官方下载地址:https://dev.mysql.com/downloads/file/?id=487211
文件名:mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
解压后文件列表:

1
2
3
4
5
6
7
8
mysql-community-client-8.0.16-2.el7.x86_64.rpm
mysql-community-common-8.0.16-2.el7.x86_64.rpm
mysql-community-devel-8.0.16-2.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.16-2.el7.x86_64.rpm
mysql-community-libs-8.0.16-2.el7.x86_64.rpm
mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm
mysql-community-server-8.0.16-2.el7.x86_64.rpm
mysql-community-test-8.0.16-2.el7.x86_64.rpm

安装

依次安装:

1
2
3
4
rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm 
rpm -ivh mysql-community-libs-*
rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm

启动或停止服务:

1
2
service mysqld start
service mysqld stop

默认会创建2个目录:/var/lib/mysql//var/lib/mysql-files/,如不存在,可手动创建。
配置文件:/etc/my.cnf

修改初始密码:
grep ‘temporary password’ /var/log/mysqld.log

数据库使用记录:
本地默认连接:
mysql -uroot -p123456
指定IP和端口:
mysql -uroot -pTest..123 -h222.84.250.173 -P3306