MySQLの5.7マルチインスタンスインストール構成

1.背景説明

。MySQLのマルチインスタンスの概念

簡単に言えば、(例えば:3306,3307)は、異なるサービス・ポートの数を開くことです複数のMySQLサービスプロセスを実行し、単一のサーバー上の上、これらのサービスは、様々な異なるソケットリスニングサービスポートを介してそのサービスを提供しています。

B。MySQLのアクションとマルチインスタンスの問題

  • サーバリソースの効率的な使用の
    残りのリソース、完全なサービスを提供するために、残りのリソースを利用することができます。
  • サーバーのリソースを節約
    、さらに、複数のインスタンスからの同期技術を習得する必要があり、すべてのより良い、会社の資金がタイトですが、彼らは独立してそのサービスを提供しようとする必要があるサーバーたときに、
  • 先取質問互いに
    同時高いまたはスロークエリのサービスがある場合には、全体のインスタンスは、サーバー上の他のインスタンスに提供されるサービスの質の低下、その結果、より多くのメモリ、CPU、ディスクIOリソースを消費します。

C。MySQLのマルチインスタンスのアプリケーションのシナリオ

  • 資金繰りが苦しい会社
  • 同時アクセスは、特に大企業ではありません
  • MySQLのマルチインスタンスアプリケーションポータルシーン

2.環境の準備

オペレーティングシステム:. CentOSのLinuxリリース1810年6月7日
BのMySQLのMySQL :.-5.7.27.tar.gz、ダウンロードする]をクリックし、MySQLのソースパッケージをコンパイルする準備ができて
、:. boost_1_59_0.tar.gzを後押しcはダウンロードする]をクリックし、MySQLの5.7をインストールしますブーストライブラリ、MySQL5.7対応するブーストバージョン1.59頼る必要があるとき
dはcmakeの:. cmakeの-2.8.12.2.tar.gzは、ダウンロードする]をクリックし、MySQLをインストールしコンパイルし、使用してcmakeの方法は、したがって、コンパイルしてインストールし、必要cmakeのインストール

3.インストール

3.1 cmakeのコンパイルとインストール

#あなたが一緒に、すべてのパッケージをディレクトリツールを作成することを推奨しました

[root@192168066012_MySQL_5_7_27 ~]# mkdir -p /home/tools/
[root@192168066012_MySQL_5_7_27 ~]# cd /home/tools/
[root@192168066012_MySQL_5_7_27 tools]# ls -l
total 143932
-rw-r--r--  1 root root 83709983 Jul 31 18:34 boost_1_59_0.tar.gz
-rw-r--r--  1 root root  6068231 Jul 31 18:36 cmake-2.8.12.2.tar.gz
-rw-r--r--  1 root root 54398696 Jul 31 18:34 mysql-5.7.27.tar.gz

#インストールパッケージを解凍してcmake

[root@192168066012_MySQL_5_7_27 tools]# tar xf cmake-2.8.12.2.tar.gz
[root@192168066012_MySQL_5_7_27 tools]# cd cmake-2.8.12.2
[root@192168066012_MySQL_5_7_27 cmake-2.8.12.2]# ll
total 3056
-rwxr-xr-x   1  501 games   53974 Jan 17  2014 bootstrap
-rw-r--r--   1  501 games  254736 Jan 17  2014 ChangeLog.manual
-rw-r--r--   1  501 games 2603523 Jan 17  2014 ChangeLog.txt
-rw-r--r--   1  501 games    5465 Jan 17  2014 CMakeCPack.cmake
-rw-r--r--   1  501 games    3436 Jan 17  2014 CMakeCPackOptions.cmake.in
-rw-r--r--   1  501 games     153 Jan 17  2014 CMakeGraphVizOptions.cmake
-rw-r--r--   1  501 games   25439 Jan 17  2014 CMakeLists.txt
-rw-r--r--   1  501 games    4481 Jan 17  2014 CMakeLogo.gif
-rw-r--r--   1  501 games     796 Jan 17  2014 cmake_uninstall.cmake.in
-rw-r--r--   1  501 games    2515 Jan 17  2014 CompileFlags.cmake
-rwxr-xr-x   1  501 games      99 Jan 17  2014 configure
-rw-r--r--   1  501 games    2637 Jan 17  2014 Copyright.txt
-rw-r--r--   1  501 games    1050 Jan 17  2014 CTestConfig.cmake
-rw-r--r--   1  501 games    3338 Jan 17  2014 CTestCustom.cmake.in
-rw-r--r--   1  501 games     145 Jan 17  2014 CTestCustom.ctest.in
-rw-r--r--   1  501 games     809 Jan 17  2014 DartConfig.cmake
-rw-r--r--   1  501 games    4144 Jan 17  2014 DartLocal.conf.in
drwxr-xr-x   3 root root      142 Aug  1 14:32 Docs
-rw-r--r--   1  501 games   28046 Jan 17  2014 doxygen.config
drwxr-xr-x   4 root root       53 Aug  1 14:32 Example
drwxr-xr-x   9 root root    16384 Aug  1 14:32 Modules
-rw-r--r--   1  501 games    1946 Jan 17  2014 Readme.txt
drwxr-xr-x   7 root root    24576 Aug  1 14:32 Source
drwxr-xr-x   2 root root     4096 Aug  1 14:32 Templates
drwxr-xr-x 169 root root     8192 Aug  1 14:32 Tests
drwxr-xr-x  15 root root     4096 Aug  1 14:32 Utilities

#コンパイルとインストールを開始

[root@192168066012_MySQL_5_7_27 cmake-2.8.12.2]# ./configure
...省略
CMake has bootstrapped.  Now run gmake.

#インストールにgmake &&にgmakeができ、[OK]を説明し、 "今すぐにgmakeを実行する" を参照してください。

[root@192168066012_MySQL_5_7_27 cmake-2.8.12.2]# gmake
...省略
[100%] Built target pseudonl_valgrind
[root@192168066012_MySQL_5_7_27 cmake-2.8.12.2]# gmake install
...省略
-- Installing: /usr/local/share/cmake-2.8/completions/ctest

ヒント:
各ステップの後、使用することができるecho $?戻り値が表す、0である場合、その通常のビルドプロセス

3.2 / usr / local /ディレクトリを抽出するためのライブラリを後押しします

#パラメータを使用して、は/ usr / local /ディレクトリにエキスを指定して、-C

[root@192168066012_MySQL_5_7_27 tools]# tar xf boost_1_59_0.tar.gz -C /usr/local/
[root@192168066012_MySQL_5_7_27 tools]# cd /usr/local/
[root@192168066012_MySQL_5_7_27 local]# mv boost_1_59_0/ boost
[root@192168066012_MySQL_5_7_27 local]# ls -l
total 0
drwxr-xr-x. 2 root root   45 Jul 30 19:49 bin
drwx------  8  501 games 302 Aug 12  2015 boost
drwxr-xr-x  3 root root   23 Jul 30 19:49 doc
drwxr-xr-x. 2 root root    6 Apr 11  2018 etc
drwxr-xr-x. 2 root root    6 Apr 11  2018 games
drwxr-xr-x. 2 root root    6 Apr 11  2018 include
drwxr-xr-x. 2 root root    6 Apr 11  2018 lib
drwxr-xr-x. 2 root root    6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root    6 Apr 11  2018 libexec
drwxr-xr-x  3 root root   18 Jul 30 19:49 man
drwxr-xr-x. 2 root root    6 Apr 11  2018 sbin
drwxr-xr-x. 7 root root   81 Jul 30 19:49 share
drwxr-xr-x. 2 root root    6 Apr 11  2018 src

3.3は、MySQL 5.7を解凍、コンパイルしてインストールします

3.3.1のインストールMySQLの依存関係5.7

[root@192168066012_MySQL_5_7_27 tools]# yum install ncurses-devel -y
...省略
Installed:
    ncurses-devel.x86_64 0:5.9-14.20130511.el7_4

Complete!
[root@192168066012_MySQL_5_7_27 tools]# yum install libaio-devel -y
...省略
Installed:
  libaio-devel.x86_64 0:0.3.109-13.el7

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7

Complete!

ヒント:
MySQLの5.7に応じてパッケージ:GCCのgcc-C ++のncurses ncursesの -develバイソン作る、などの参考のためには、rpm -qaをインストールする前に、使用することができます| grepを$ {name}のチェックパッケージ

3.3.2 MySQLのファイル格納ディレクトリ、ユーザとグループを作成します

#関連文書とよりのMySQLインスタンスのリストを作成します。

[root@192168066012_MySQL_5_7_27 tools]# mkdir -p /application/mysql
[root@192168066012_MySQL_5_7_27 tools]# mkdir -p /application/mysql/logs
[root@192168066012_MySQL_5_7_27 tools]# mkdir -p /application/mysql/data/{3306,3307}/data
[root@192168066012_MySQL_5_7_27 tools]# tree -L 3 /application/mysql/data/
/application/mysql/data/
|-- 3306
|   `-- data
`-- 3307
    `-- data

4 directories, 0 files

#mysqlのユーザーおよびグループを作成します。

[root@192168066012_MySQL_5_7_27 tools]# groupadd mysql
[root@192168066012_MySQL_5_7_27 tools]# useradd mysql -s /sbin/nologin -M -g mysql
[root@192168066012_MySQL_5_7_27 tools]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)

説明:
-s / sbinに/ nologinにユーザーがログインできない
-Mは、ユーザのホームディレクトリを作成していない
ユーザーがログオンの-g GIDまたはグループ名指定したグループを

3.3.3コンパイルおよびMySQL 5.7をインストールします

#ソースインストールパッケージのmysql-5.7.27.tar.gzを抽出

[root@192168066012_MySQL_5_7_27 tools]# cd /home/tools/
[root@192168066012_MySQL_5_7_27 tools]# tar xf mysql-5.7.27.tar.gz

#cmakeコンパイラの設定パラメータ

[root@192168066012_MySQL_5_7_27 tools]# cd mysql-5.7.27
[root@192168066012_MySQL_5_7_27 mysql-5.7.27]# cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql \
 -DMYSQL_DATADIR=/application/mysql/data \
 -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock \
 -DDEFAULT_CHARSET=utf8 \
 -DDEFAULT_COLLATION=utf8_general_ci \
 -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
 -DENABLED_LOCAL_INFILE=ON \
 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 -DWITH_FEDERATED_STORAGE_ENGINE=1 \
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
 -DWITH_ZLIB=bundled \
 -DWITH_EMBEDDED_SERVER=1 \
 -DWITH_DEBUG=0 \
 -DWITH_BOOST=/usr/local/boost

#実行makeが継続してインストールし、cmakeのはコンパイルに、以下のメッセージを参照してください。

 -- Configuring done
 -- Generating done
 -- Build files have been written to: /home/tools/mysql-5.7.27

#make installをインストールを続行し続け

...省略
 Linking CXX executable my_safe_process
 [100%] Built target my_safe_process

#インストールは完了です

...省略
 -- Installing: /application/mysql-5.7.27/share/aclocal/mysql.m4
 -- Installing: /application/mysql-5.7.27/support-files/mysql.server

ヒント:
そのエラーが発生していない場合は(?各ステップの終了後、あなたは0が正しいを示し、値が0であるかどうかを確認しますecho $リターンを使用することができます)表示/アプリケーション/ mysqlの/ディレクトリに、それは下のコンテンツがある場合、それはMySQL5.7.27パケットはソースコード正常にインストールcmakeのを使用して表し

MySQLの3.4コンフィギュレーションシステム環境変数

[root@192168066012_MySQL_5_7_27 ~]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
[root@192168066012_MySQL_5_7_27 ~]# tail -1 /etc/profile
export PATH=/application/mysql/bin:$PATH

#/ etc / profileを設定ファイルには、すぐに有効になります

[root@192168066012_MySQL_5_7_27 ~]# source /etc/profile
[root@192168066012_MySQL_5_7_27 ~]# echo $PATH
/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

3.5データベースを初期化します

3.5.1 my.cnfの設定ファイル

#は、ファイルを変更な/etc/my.cnf、およびバージョンは以前の5.6にバージョン5.7のサポート・ファイルのディレクトリの下には.cnfのファイルは、そのため、手動で編集する必要があり、同じではないではありません

[root@192168066012_MySQL_5_7_27 ~]# cp /etc/my.cnf /etc/my.cnf.bak
[root@192168066012_MySQL_5_7_27 ~]# vim /etc/my.cnf
[mysqld_multi]
mysqld = /application/mysql/bin/mysqld
mysqladmin = /application/mysql/bin/mysqladmin
log = /application/mysql/logs/mysql_multi.log

[mysqld1]
port = 3306
user = mysql
character_set_server = utf8
socket = /application/mysql/data/3306/mysql.sock
datadir = /application/mysql/data/3306/data
pid-file = /application/mysql/data/3306/mysql.pid
log-bin = /application/mysql/data/3306/mysql-bin
server-id = 1
log-error = /application/mysql/data/3306/mysql_boyu3306.err

[mysqld2]
port = 3307
user = mysql
character_set_server = utf8
socket = /application/mysql/data/3307/mysql.sock
datadir = /application/mysql/data/3307/data
pid-file = /application/mysql/data/3307/mysql.pid
log-bin = /application/mysql/data/3307/mysql-bin
server-id = 3
log-error = /application/mysql/data/3307/mysql_boyu3307.err

ヒント:
新しいMySQLインスタンスは、ポートとサーバーID、例にmy.cnfの設定ファイルと起動スクリプトを変更するには注意を払い、すでに実行している競合しません。

3.5.2属のmy.cnfファイルの所有者とグループを変更します

[root@192168066012_MySQL_5_7_27 ~]# chown mysql:mysql /etc/my.cnf

3.5.3の変更所有者とグループのMySQLのインストールディレクトリ

[root@192168066012_MySQL_5_7_27 ~]# chown -R mysql:mysql /application/mysql/

3.5.4データベースの初期化

[root@192168066012_MySQL_5_7_27 data]# cd /application/mysql/
[root@192168066012_MySQL_5_7_27 mysql]# ./bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/3306/data/
2019-08-07T03:33:57.693586Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-08-07T03:33:57.973904Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-08-07T03:33:58.013774Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-08-07T03:33:58.070602Z 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: 30a49b8b-b8c4-11e9-b40d-000c290943d8.
2019-08-07T03:33:58.072487Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-08-07T03:33:58.074274Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@192168066012_MySQL_5_7_27 mysql]# ./bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/3307/data/
2019-08-07T03:34:06.558576Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-08-07T03:34:06.792397Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-08-07T03:34:06.835971Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-08-07T03:34:06.893802Z 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: 35e6eba6-b8c4-11e9-b7dc-000c290943d8.
2019-08-07T03:34:06.896053Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-08-07T03:34:06.897815Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

ヒント:
初期化が失敗し、次のように初期化、データディレクトリは空でなければなりませんが、そうでない場合は、情報が与えられます

2019-08-07T06:58:34.828541Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-08-07T06:58:34.828576Z 0 [ERROR] Aborting

なぜデータベースを初期化する必要がありますか?
。初期化の主な目的は、例えば、に基づいてデータベースを作成することである:MySQLデータベースを生成し、テーブル、等
インスタンスに対応する初期化データディレクトリ後のB図、次の情報を見ることができます。

[root@192168066012_MySQL_5_7_27 mysql]# tree -L 3 /application/mysql/data/
/application/mysql/data/
|-- 3306
|   `-- data
|       |-- auto.cnf
|       |-- ib_buffer_pool
|       |-- ibdata1
|       |-- ib_logfile0
|       |-- ib_logfile1
|       |-- mysql
|       |-- performance_schema
|       `-- sys
`-- 3307
    `-- data
        |-- auto.cnf
        |-- ib_buffer_pool
        |-- ibdata1
        |-- ib_logfile0
        |-- ib_logfile1
        |-- mysql
        |-- performance_schema
        `-- sys

10 directories, 10 files

3.5.5オープンSSL接続例

[root@192168066012_MySQL_5_7_27 mysql]# /application/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/3306/data/
Generating a 2048 bit RSA private key
.....................+++
......+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
............+++
.................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
........................................................+++
...............................+++
writing new private key to 'client-key.pem'
-----
[root@192168066012_MySQL_5_7_27 mysql]# /application/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/3307/data/
Generating a 2048 bit RSA private key
..................................................................+++
..............................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.....+++
...............................................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.........+++
......+++
writing new private key to 'client-key.pem'
-----

3.5.6ディレクトリデータにサーバーkey.pemファイルのパーミッションを変更

[root@192168066012_MySQL_5_7_27 ~]# cd /application/mysql/data/3306/data/
[root@192168066012_MySQL_5_7_27 data]# chmod +r server-key.pem
[root@192168066012_MySQL_5_7_27 data]# ls -lh server-key.pem
-rw-r--r-- 1 root root 1.7K Aug  7 15:07 server-key.pem
[root@192168066012_MySQL_5_7_27 data]# cd /application/mysql/data/3307/data/
[root@192168066012_MySQL_5_7_27 data]# chmod +r server-key.pem
[root@192168066012_MySQL_5_7_27 data]# ls -lh server-key.pem
-rw-r--r-- 1 root root 1.7K Aug  7 15:07 server-key.pem

ヒント:
あなたは与えていない場合は、時間がデータベースを起動するとき、次のエラー報告しますように、サーバー・key.pem他のユーザーおよびグループは、ファイルへのアクセスを読ん
39:24.111526Z 0 [ERROR 2019-08-07T06 ] SSLエラー:取得することができませんキーのプライベート「サーバー-key.pem」から
39:24.111555Z 0 [警告]ため、SSLライブラリ次のエラーで失敗にSSLを設定します。プライベートキーを取得することができません2019-08-07T06

3.6 MySQLデータベースを開始

次/etc/init.d/のディレクトリにコピー3.6.1起動スクリプトは、mysqld_multiの名前を変更し、実行権限を与えます

[root@192168066012_MySQL_5_7_27 ~]# cd /application/mysql
[root@192168066012_MySQL_5_7_27 mysql]# cp support-files/mysqld_multi.server /etc/init.d/mysqld_multi
[root@192168066012_MySQL_5_7_27 mysql]# chmod +x /etc/init.d/mysqld_multi
[root@192168066012_MySQL_5_7_27 mysql]# ll /etc/init.d/mysqld_multi
-rwxr-xr-x 1 root root 1061 8月   7 11:38 /etc/init.d/mysqld_multi

3.6.2スクリプトとMySQLのインストールディレクトリのbinディレクトリの絶対パスを変更します

[root@192168066012_MySQL_5_7_27 mysql]# diff /application/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi
17,18c17,18
< basedir=/usr/local/mysql
< bindir=/usr/local/mysql/bin
---
> basedir=/application/mysql
> bindir=/application/mysql/bin

ヒント:
MySQLはは/ usr / local /ディレクトリにインストールされていない場合、あなたはマルチ・インスタンスを変更する必要がありますが、起動スクリプト、BASEDIR = $ {MySQLのインストールディレクトリ}、$ BINDIR = {MySQLインストールディレクトリ下のbinディレクトリ}、そうでない場合は、起動スクリプトをmysqld_multi "は/ usr / localを実行することはできません報告されますディレクトリは/ usr / local / mysqlのから/ mysqlの/ binに/ mysqld_multi" エラー。

3.6.3リロードシステムサービスは、開始からMySQLデータベースの起動に参加します

[root@192168066012_MySQL_5_7_27 mysql]# /bin/systemctl daemon-reload
[root@192168066012_MySQL_5_7_27 mysql]# /bin/systemctl enable mysqld_multi
mysqld_multi.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld_multi on
[root@192168066012_MySQL_5_7_27 mysql]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld_multi    0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off

[スタート] MySQLデータベース3.6.4、およびポートの監視のステータスをチェック

[root@192168066012_MySQL_5_7_27 mysql]# /etc/init.d/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld1 is not running
MySQL server from group: mysqld2 is not running
[root@192168066012_MySQL_5_7_27 mysql]# /etc/init.d/mysqld_multi start
[root@192168066012_MySQL_5_7_27 mysql]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      6568/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      6814/master
tcp6       0      0 :::3306                 :::*                    LISTEN      7404/mysqld
tcp6       0      0 :::3307                 :::*                    LISTEN      7407/mysqld
tcp6       0      0 :::22                   :::*                    LISTEN      6568/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      6814/master

3.7 MySQLのデータベース接続

3.7.1着陸指定されたソケット3306のデータベース

[root@192168066012_MySQL_5_7_27 mysql]# mysql -S /application/mysql/data/3306/mysql.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27-log Source distribution

Copyright (c) 2000, 2019, 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> \q
Bye

3.7.2着陸指定されたソケット3307のデータベース

[root@192168066012_MySQL_5_7_27 mysql]# mysql -S /application/mysql/data/3307/mysql.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27-log Source distribution

Copyright (c) 2000, 2019, 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> \q
Bye

ヒント:
。ローカルにログオン

  • 複数のインスタンスは、MySQL初期設定で指定された特定の場所は、ログイン手順がソケットファイルを着陸データベースインスタンスによって決定されるソケットファイルマシンログインを通してインスタンスを着陸したローカル端末着陸を指定します
  • 通信でのローカルクライアントファイルUnixソケットを持つにmysql.sock <==ファイルサーバ
  • たとえば:mysqlの-Sの/application/mysql/data/3306/mysql.sockは3306データベースインスタンスを上陸させました

B。Telnetの

  • Telnetは、このポートは、my.cnfのMySQLの設定ファイルで指定されている、あなたがログインすることを指定するには、マルチインスタンスのホスト、TCP / IPポート(ポート)のMySQLインスタンスのインスタンスを指定します。
  • ポート<==ポートは仕方特定のサービス・ルーチンが割り当てられている「論理的な接続位置、」コンピュータ上のクライアントプログラムです
  • Telnetのケース:
  • グラント上のすべての権限リモートアクセスなど、MySQLサーバにすべての権限を与えられたクライアント192.168.66.11に#、;ルート@には「192.168.66.11」は「boyu123」で識別されます
  • フラッシュ権限;#は、権限テーブルのMySQLをリロード
  • #変更の結果を見る、ユーザを選択し、mysqlの、ユーザーからホストを
  • mysqlの-uroot -p'boyu123「-h 192.168.66.12 -P上記192.168.66.11で実行このコマンドは、リモート・データベースにログインすることができます3306#

3.8基本的なデータベース操作

3.8.1マルチインスタンスのログインパスワードを変更します

[root@192168066012_MySQL_5_7_27 mysql]# mysqladmin -u root -p password "boyu123" -S /application/mysql/data/3306/mysql.sock
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@192168066012_MySQL_5_7_27 mysql]# mysqladmin -u root -p password "boyu123" -S /application/mysql/data/3307/mysql.sock
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

3.8.2近いエレガントなマルチインスタンス・データベース

#使用してMySQLの組み込みのスクリプト

[root@192168066012_MySQL_5_7_27 mysql]# /etc/init.d/mysqld_multi stop
[root@192168066012_MySQL_5_7_27 mysql]# ps aux|grep mysqld
root      23962  0.0  0.0 112708   976 pts/0    S+   20:39   0:00 grep --color=auto mysqld

ヒント:この方法はまた、上記のすべてのデータベースサーバをシャットダウンしますあなたは一つ一つをシャットダウンしたい場合、あなたはmysqladminのメソッドを使用することができます

#使用mysqladminの方法

[root@192168066012_MySQL_5_7_27 mysql]# mysqladmin -uroot -p"boyu123" -S /application/mysql/data/3307/mysql.sock shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
[root@192168066012_MySQL_5_7_27 mysql]# ps aux|grep mysqld
mysql     24058  0.1 10.1 1181012 188944 pts/0  Sl   20:39   0:01 /application/mysql/bin/mysqld --port=3306 --user=mysql --character_set_server=utf8 --socket=/application/mysql/data/3306/mysql.sock --datadir=/application/mysql/data/3306/data --pid-file=/application/mysql/data/3306/mysql.pid --log-bin=/application/mysql/data/3306/mysql-bin --server-id=1 --log-error=/application/mysql/data/3306/mysql_boyu3306.err
root      28235  0.0  0.0 112708   976 pts/0    S+   20:51   0:00 grep --color=auto mysqld

おすすめ

転載: blog.51cto.com/14463906/2427362