mysql5.7バージョンの詳細なバイナリインストール

1.ソフトウェアインストールパッケージをダウンロードします

サーバー:118.190.152.60
mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz

2.mysqlユーザーを作成します

useradd mysql
passwd mysql_123456
ログインを許可しないようにユーザーを作成します。ログインを許可しないように既存のユーザー

変更するには、rootユーザーに注意してください。usermod-
s/ sbin / nologin
新しいユーザーはログインは許可されていません:
useradd -s / sbin / nologin

3.mysql5.7バージョンに必要なディレクトリを作成します

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

4. MySQL5.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]# 

mysqlバイナリパッケージを解凍します
[root @ VM_0_8_centos opt] #tar -zxvfmysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
ディレクトリ権限を変更します
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:$パス '>> / etc / profile
source / etc / profile

5.mysql5.7バージョンデータベースを初期化します
[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 ~

my9571.cnfの権限を表示する

[root @ ttlsa〜] #ls -l my9571.cnf
-rwxrwxrwx 1 root root 4878 Jul 30 11:31 my9571.cnf
パーミッション777、すべてのユーザーがmy9571.cnfを変更でき、大きなセキュリティリスクがあります
。MySQLの問題を修正してください
[root @ VM_0_8_centos conf] #chmod 644 my9571.cnf

6.mysql5.7バージョンデータベースを起動します
[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/

これは開始するバックグラウンドプロセスではないことに注意してください。データベースが切断されると、端末は強制終了されます。
mysqlを停止する方法
[root @ VM_0_2_centosログ] #mysqladmin -uroot -p shutdown -S /data/mysql/9571/run/mysql9571.sock
パスワードを入力してください:

7.データベースにログインします
[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.バックグラウンドでmysqlを起動します
[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.ルートパスワードを変更します

変更を有効にするには、変更後に再起動する必要があります

[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]# 

別のユーザーを作成する

 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.変更後にログインします
[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]# 

おすすめ

転載: blog.csdn.net/qq_31555951/article/details/107085099