mysql8.0 deployment, initialization and instance creation

mysql8.0 deployment, initialization and instance creation

Environment information:
centos 7.4.1708
mysql 8.0.11

1. Download and unzip the mysql package

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. Initialize mysql basic environment information

vim /etc/profile
PATH=/opt/mysql/bin:/opt/mysql/lib:$PATH
export PATH
export MYSQL_HOME="/opt/mysql"
export ms="/opt/mysql"

3. Initialize the configuration instance configuration file

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. Create a new user

groupadd mysql
useradd mysql -g mysql
chown mysql:mysql /opt/mysql -R

5. Initialize the mysql instance
/opt/mysql/bin/mysqld --initialize --basedir=/opt/mysql --datadir=/opt/mysql/data/mcdb --user=mysql
to obtain the password from the last line of the returned information, for example:
xHGkgc+9ea6/

6. Start the instance 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. Login to mysql
/opt/mysql/bin/mysql -uroot -pxHGkgc+9ea6/ -S /opt/mysql/data/mcdb/mysql.sock

8. Set a new password
set password = 'hello2018';

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324605196&siteId=291194637