Detailed binary installation of mysql5.7 version

1. Download the software installation package

Server: 118.190.152.60
mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz

2. Create a mysql user

useradd mysql
passwd mysql_123456
Create a user so that it is not allowed to log in:
Please pay attention to the root user to
modify an existing user so that it is not allowed to log in:
usermod -s /sbin/nologin A
new user is not allowed to log in:
useradd -s /sbin/ nologin

3. Create the directory required by mysql5.7 version

mkdir -pv /data/mysql/mysql9571/{conf,data,logs,run,tmp}

4. Create the configuration file required by MySQL 5.7
[root@iZm5eckxl2tqyk76wy33pkZ ~]# cd /data/mysql/mysql9571/conf/
[root@iZm5eckxl2tqyk76wy33pkZ conf]# more my9571.cnf 
[client]
default-character-set=utf8
port = 9571
socket = /data/mysql/mysql9571/run/mysql9571.sock
[mysqld]
user = mysql
port = 9571
character_set_server=utf8
init_connect='SET NAMES utf8'
socket = /data/mysql/mysql9571/run/mysql9571.sock
basedir = /opt/mysql-5.7.11-linux-glibc2.5-x86_64/
datadir = /data/mysql/mysql9571/data
log-error = /data/mysql/mysql9571/data/error.log
pid-file = /data/mysql/mysql9571/run/mysql9571.pid
tmpdir = /data/mysql/mysql9571/tmp
slow-query-log-file = /data/mysql/mysql9571/data/9571slow.log
log-bin = mysql-bin
binlog_format = row

server-id = 111
binlog-ignore-db = information_schema
binlog-ignore-db = cluster
binlog-ignore-db = mysql
binlog-do-db=test
[root@iZm5eckxl2tqyk76wy33pkZ conf]# 

Unzip the mysql binary package
[root@VM_0_8_centos opt]# tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
Modify the directory permissions
chown -R mysql.mysql /opt/mysql-5.7.11-linux -glibc2.5-x86_64/
chown -R mysql.mysql /data/mysql/mysql9571/
configure environment variable echo'export
PATH=/opt/mysql-5.7.11-linux-glibc2.5-x86_64/bin:$PATH' >> /etc/profile
source /etc/profile

5. Initialize the mysql5.7 version database
[root@iZm5eckxl2tqyk76wy33pkZ conf]# cd /opt/mysql-5.7.11-linux-glibc2.5-x86_64/
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# ./bin/mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql-5.7.11-linux-glibc2.5-x86_64 --datadir=/data/mysql/mysql9571/data/
2018-05-26T13:28:52.343461Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-26T13:28:53.463429Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-26T13:28:53.666121Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-26T13:28:53.738045Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: bbfcb5fa-60e8-11e8-bac6-00163e05510e.
2018-05-26T13:28:53.757450Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-26T13:28:53.757951Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# cd ~

View the permissions of my9571.cnf

[root@ttlsa ~]# ls -l my9571.cnf
-rwxrwxrwx 1 root root 4878 Jul 30 11:31 my9571.cnf
permission 777, any user can change my9571.cnf, there is a big security risk.
Fix MySQL problem
[root@VM_0_8_centos conf]# chmod 644 my9571.cnf

6. Start the mysql5.7 version database
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# ./bin/mysqld --defaults-file=/data/mysql/mysql9571/conf/my9571.cnf
[root@iZm5eckxl2tqyk76wy33pkZ conf]# cd /opt/mysql-5.7.11-linux-glibc2.5-x86_64/

Note that this is not a background process to start, the terminal will be killed if the database is disconnected.
How to stop mysql
[root@VM_0_2_centos logs]# mysqladmin -uroot -p shutdown -S /data/mysql/9571/run/mysql9571.sock
Enter password:

7. Log in to the database
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# ./bin/mysql -S /data/mysql/mysql9571/run/mysql9571.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# netstat -nltp
8. Start mysql in the background
[root@iZm5eckxl2tqyk76wy33pkZ ~]# cd /opt/mysql-5.7.11-linux-glibc2.5-x86_64/
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# ./bin/mysqld --defaults-file=/data/mysql/mysql9571/conf/my9571.cnf &
[1] 2982
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# 
9. Modify the root password

Need to restart after modification to take effect

[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# ./bin/mysql -S /data/mysql/mysql9571/run/mysql9571.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.11-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update mysql.user set authentication_string=password('d7g91GzkR*ie%#o@') where user='root' and Host = 'localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1
flush privileges;
mysql> exit
Bye
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# 

Create another user

 mysql> grant all on *.* to 'test_db'@'%' identified by 'xiajing367300';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye
[root@VM_0_8_centos mysql-5.7.11-linux-glibc2.5-x86_64]
10. Login after modification
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# ./bin/mysql -uroot -p -S /data/mysql/mysql9571/run/mysql9571.sock
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.11-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
[root@iZm5eckxl2tqyk76wy33pkZ mysql-5.7.11-linux-glibc2.5-x86_64]# 

Guess you like

Origin blog.csdn.net/qq_31555951/article/details/107085099