环境信息: CentOS 7.4.1708 MySQL 8.0.11
1.下载解压缩mysql包
cd /usr/local/ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz tar xzvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz mv mysql-8.0.11-linux-glibc2.12-x86_64 mysql
2.初始化mysql基础环境信息
vim /etc/profile PATH=/opt/mysql/bin:/opt/mysql/lib:$PATH export PATH export MYSQL_HOME="/opt/mysql" export ms="/opt/mysql"
3.初始化配置实例配置文件
mkdir -p /opt/mysql/data/mcdb vi /opt/mysql/data/my.cnf
[client] port = 3311 socket = /opt/mysql/data/mcdb/mysql.sock [mysql] no-auto-rehash [mysqld] user = mysql port = 3311 socket = /opt/mysql/data/mcdb/mysql.sock basedir = /opt/mysql datadir = /opt/mysql/data pid-file = /opt/mysql/data/mcdb/mysql.pid relay-log = /opt/mysql/data/mcdb/relay-bin relay-log-info-file = /opt/mysql/data/mcdb/relay-log.info server-id = 13 [mysqld_safe] log-error = /opt/mysql/data/mcdb/mysql.err pid-file = /opt/mysql/data/mcdb/mysql.pid
4.新建用户
groupadd mysql useradd mysql -g mysql chown mysql:mysql /opt/mysql -R
5.初始化mysql实例 /opt/mysql/bin/mysqld --initialize --basedir=/opt/mysql --datadir=/opt/mysql/data/mcdb --user=mysql 从返回信息最后一行获得密码,举个栗子: xHGkgc+9ea6/
6.启动该实例mysql
mv /opt/mysql/data/my.cnf /opt/mysql/data/mcdb/my.cnf /opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/data/mcdb/my.cnf --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data/mcdb 2>&1 > /dev/null &
7.登录mysql /opt/mysql/bin/mysql -uroot -pxHGkgc+9ea6/ -S /opt/mysql/data/mcdb/mysql.sock
8.设定新密码 set password = 'hello2018';