1、 上传介质文件
scp -P port 135.129.12.49:/usr/local/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz ./usr/local
2、 解压文件
cd /usr/local/
tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
3、创建软连接
ln -s mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz mysql
4、更改权限
chown -R mysql:mysql mysql
5、编辑参数文件
vim /etc/my.cnf
[mysqld]
datadir = /mysqldata/my3306/data
socket = /mysql/my3306/mysql.sock
pid_file = /mysql/my3306/mysql.pid
server_id = 3299
port = 3306
binlog_format = ROW
log_bin = mysql-bin
log_bin_index = mysql-bin.index
relay_log = relay-log
relay_log_index = relay-log.index
log_error = error.log
general_log_file = general.log
slow_query_log_file = slow.log
long_query_time = 1
slow_query_log = ON
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
explicit_defaults_for_timestamp = ON
lower_case_table_names = 1
transaction_isolation = READ-COMMITTED
open_files_limit = 65535
enforce_gtid_consistency = ON
gtid_mode = ON
log_slave_updates = ON
6、创建文件目录及赋权
mkdir -p /mysqldata/my3306/data
chown -R mysql:mysql /mysqldata/my3306/data
mkdir -p /mysql/my3306/
chown -R mysql:mysql /mysql/my3306/
7、初始化数据库
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize-insecure
8、启动数据库
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
9、登录数据库
/usr/local/mysql/bin/mysql -uroot -S /mysql/my3306/mysql.sock -p
10、修改root密码
alter user root@‘localhost’ identified by ‘123’;
flush privileges;
11、重新登录数据库
/usr/local/mysql/bin/mysql -uroot -S /mysql/my3306/mysql.sock -p123