# useradd mysql
2、创建数据和日志目录
# mkdir -p /data/mysql/data_3306 # mkdir -p /data/mysql/binlog_3306
3、下载安装包并安装
# cd /usr/local/ # wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz # tar xf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz # ln -s mysql-8.0.16-linux-glibc2.12-x86_64 mysql8 # yum install libaio libaio-devel -y
4、设置环境变量
# vim /etc/profile export PATH=/usr/local/mysql8/bin:$PATH # source /etc/profile
5、权限设置
# chown -R mysql.mysql /data /usr/local/mysql*
6、初始化
# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/mysql/data_3306
7、启动数据库
# yum remove -y mariadb-libs # more /etc/my.cnf [mysqld] user=mysql basedir=/usr/local/mysql57 datadir=/data/mysql/data_3306 socket=/tmp/mysql.sock server_id=1 log_bin=/data/mysql/binlog_3306 port=3306 [mysql] socket=/tmp/mysql.sock # cp /usr/local/mysql57/support-files/mysql.server /etc/init.d/mysqld # chkconfig --add mysqld
8、登录数据库
# systemctl start mysqld # mysql mysql>