Mysql8 Centos8 使用编译好的包安装

mysql8安装

下载编译好的安装包

清华镜像站下载安装包

下载安装包

1
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.11-el7-x86_64.tar.gz

创建新用户

1
2
3
useradd mysql
tar xvfz mysql-8.0.11-el7-x86_64.tar.gz
cd mysql-8.0.11-el7-x86_64

初始化数据库

1
mysqld --initialize --user=mysql

创建 my.cnf 文件

1
2
3
4
5
6
7
8
9
[mysqld]
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp

[client]
socket=/var/lib/mysql/mysql.sock

配置服务

1
2
3
4
5
cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start

初始化表和权限

1
mysql_secure_installation

修改 root 密码

1
2
alter user 'root'@'localhost' identified by 'newpassword';
flush privileges;