1. Background Description
a. MySQL multi-instance concept
Simply put, is to open a number of different service ports (such as: 3306,3307) above on a single server, run multiple MySQL service process, these services provide their services through various different socket listening service port.
b. MySQL action and multi-instance issues
- Efficient use of server resources
resources remaining, can fully utilize the remaining resources to provide services;- Saving server resources
when the company funds are tight, but the server they need to try to provide their services independently; moreover, need to master synchronization technology from multiple instances, all the better;- Pre-emption question each other
when there is a service of concurrent high or slow query, the entire instance will consume more memory, CPU, disk IO resources, resulting in a decline in the quality of services provided to other instances on the server;c. MySQL multi-instance application scenarios
- Cash-strapped company
- Concurrent access is not a particularly big business
- MySQL multi-instance application portal scene
2. Preparing the Environment
a Operating System:. CentOS Linux Release 7.6.1810
b MySQL:. MySQL-5.7.27.tar.gz, click to download , ready to compile MySQL source package
c boost:. boost_1_59_0.tar.gz, click to download , install MySQL 5.7 when the need to rely boost libraries, MySQL5.7 corresponding boost version 1.59
d cmake:. cmake-2.8.12.2.tar.gz, click to download , compile install MySQL, use cmake way compile and install, therefore, need install cmake
3. INSTALLATION
3.1 compile and install cmake
# Recommended that you create a directory tools, all the packages together
[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
# Extract the installation package 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
# Compile and install begin
[root@192168066012_MySQL_5_7_27 cmake-2.8.12.2]# ./configure
...省略
CMake has bootstrapped. Now run gmake.
# See "Now run gmake" explained ok, can gmake && gmake install
[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
Tip:
After each step, may be usedecho $?
, when the return value is 0, indicating that the normal build process
3.2 will boost library to extract the / usr / local / directory
# Specify extract to / usr / local / directory, using parameters -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 unpack MySQL 5.7, compile and install
3.3.1 Installing MySQL dependencies 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!
Tip:
MySQL 5.7 packages depending on: gcc gcc-c ++ ncurses ncurses -devel bison make , etc. for reference, can be used before installing the rpm -qa | grep $ {name} check packages
3.3.2 Creating a MySQL file storage directory, user and group
# Create a list of related documents and more MySQL instances
[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
# Create mysql user and group
[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)
Description:
-s / sbin / nologin Users can not log
-M do not create the user's HOME directory
-g GID or group name specified group of users log on
3.3.3 compile and install MySQL 5.7
# Extract the source installation package 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 compiler configuration parameters
[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
# See the message below, cmake to compile, run make install to continue
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tools/mysql-5.7.27
# Continue to continue the installation make install
...省略
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
#The installation is complete
...省略
-- Installing: /application/mysql-5.7.27/share/aclocal/mysql.m4
-- Installing: /application/mysql-5.7.27/support-files/mysql.server
Tip:
If that error does not occur (after the end of each step, you can use echo $ return to see whether the value is 0, 0 indicates correct?) View / application / mysql / directory, if it has a lower content, It represents MySQL5.7.27 packet uses source code successfully installed cmake
MySQL 3.4 configuration system environment variables
[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
# The / etc / profile configuration file take effect immediately
[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 initialize the database
3.5.1 my.cnf configuration file
# /Etc/my.cnf modify files, and versions prior to 5.6 are not the same, no .cnf files under version 5.7 support-files directory, therefore, you need to manually edit
[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
Tip:
When new MySQL instance, pay attention to change my.cnf configuration files and startup scripts in port and server-id, examples and do not conflict already running;
3.5.2 modify the my.cnf file owner and group of the genus
[root@192168066012_MySQL_5_7_27 ~]# chown mysql:mysql /etc/my.cnf
3.5.3 Change the MySQL installation directory of the owner and group
[root@192168066012_MySQL_5_7_27 ~]# chown -R mysql:mysql /application/mysql/
3.5.4 database initialization
[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.
Tip:
initialization, data directory must be empty, otherwise the initialization fails, the information will be given as follows2019-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
Why should initialize the database?
. A primary purpose of initialization is to create a database based on, for example: generating a MySQL database, tables, etc.
b view after initialization data directory corresponding to the instance, the following information can be seen.[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 Open SSL connection Examples
[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 modify server-key.pem file permissions in the directory data
[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
Tip:
If you do not give server-key.pem other users and groups read access to the file, so that when the time to start the database, will report the following error
2019-08-07T06: 39: 24.111526Z 0 [ERROR ] SSL error: Unable to get from Key Private 'Server-the key.pem'
2019-08-07T06: 39: 24.111555Z 0 [Warning] SET up the SSL to the Failed Because of the SSL Library The following error: Unable to GET Private Key
3.6 start the MySQL database
3.6.1 copy startup script to the next /etc/init.d/ directory, rename mysqld_multi, and give executable permissions
[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 modify scripts and MySQL installation directory bin directory absolute path
[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
Tip:
If MySQL is not installed in / usr / local / directory, you need to modify multi-instance mysqld_multi startup script, basedir = $ {MySQL installation directory}, bindir = {bin directory under the MySQL installation directory} $, otherwise startup script It will be reported "can not execute / usr / local / mysql / bin / mysqld_multi from dir / usr / local / mysql" error;
3.6.3 reload system services, will join MySQL database boot from the start
[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
3.6.4 Start MySQL database, and check the status of port monitoring
[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 database connection
3.7.1 landing specified socket 3306 database
[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 landing specified socket 3307 database
[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
Tip:
. A log on locally
- Multiple instances to specify which local terminal landing to landing instance through socket file that the specific location specified in the mysql initialization, the login procedure is determined by the database instance landing socket file when the machine login
- mysql.sock <== file server with the local client file Unix socket in communication
- For example: mysql -S /application/mysql/data/3306/mysql.sock landed 3306 database instance
b. Telnet
- Telnet specify an instance of multi-instance host, mysql instance of TCP / IP port (port) to specify that you want to log in, this port is specified in the my.cnf MySQL configuration file.
- port <== port is a "logical connection position," the client program on the computer is assigned a manner specific service routine
- Telnet Case:
- All privileges ON Grant . to root @ "192.168.66.11" IDENTIFIED by "boyu123"; # to the client 192.168.66.11 given all privileges in the MySQL server, including remote access
- flush privileges; # reload the grant tables mysql
- # View the result of changes; select user, host from mysql, user
- mysql -uroot -p'boyu123 '-h 192.168.66.12 -P 3306 # This command executed at 192.168.66.11 above, you can log in to a remote database
3.8 The basic database operations
3.8.1 modify multi-instance login password
[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 close elegant multi-instance database
# Using MySQL built-in script
[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
Tip: This method will also shut down all database servers above, if you want to shut down one by one, you can use mysqladmin method
# Use mysqladmin method
[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