Mariadb/MySQL多实例实战

                                作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.安装MySQL程序

  无论你喜欢哪种方式安装均可,关于源码安装,yum安装或者二进制安装,可以参考官网文档,也可以参考网络上的博客之类的,推荐参考我之前写的笔记。

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie/p/11733897.html

二.基于已经安装的MySQL程序启动三个实例(即三个实例公用同一套MySQL程序)

1>.创建多实例各自的数据库存储目录

[root@node105.yinzhengjie.org.cn ~]# yum -y install tree
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.huaweicloud.com
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.huaweicloud.com
base | 3.6 kB ::
extras | 2.9 kB ::
updates | 2.9 kB ::
(/): base//x86_64/group_gz | kB ::
(/): extras//x86_64/primary_db | kB ::
(/): base//x86_64/primary_db | 6.0 MB ::
(/): updates//x86_64/primary_db | 2.8 MB ::
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 :1.6.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================
Installing:
tree x86_64 1.6.-.el7 base k Transaction Summary
=========================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
tree-1.6.-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tree-1.6.-.el7.x86_64 /
Verifying : tree-1.6.-.el7.x86_64 / Installed:
tree.x86_64 :1.6.-.el7 Complete!
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# yum -y install tree

[root@node105.yinzhengjie.org.cn ~]# mkdir -pv /mysql/{,,}            #创建MySQL对应实例存放目录
mkdir: created directory ‘/mysql’
mkdir: created directory ‘/mysql/’
mkdir: created directory ‘/mysql/’
mkdir: created directory ‘/mysql/’
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# tree /mysql/      #三个目录存放各自的实例
/mysql/
├──
├──
└── directories, files
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mkdir -pv /mysql/{3306,3307,3308} #创建MySQL对应实例存放目录

[root@node105.yinzhengjie.org.cn ~]# mkdir -pv /mysql/{,,}/{etc,socket,log,pid,data}  #别分创建各个实例对应文件存储路径,目录最好见名知意。
mkdir: created directory ‘/mysql//etc’
mkdir: created directory ‘/mysql//socket’
mkdir: created directory ‘/mysql//log’
mkdir: created directory ‘/mysql//pid’
mkdir: created directory ‘/mysql//data’
mkdir: created directory ‘/mysql//etc’
mkdir: created directory ‘/mysql//socket’
mkdir: created directory ‘/mysql//log’
mkdir: created directory ‘/mysql//pid’
mkdir: created directory ‘/mysql//data’
mkdir: created directory ‘/mysql//etc’
mkdir: created directory ‘/mysql//socket’
mkdir: created directory ‘/mysql//log’
mkdir: created directory ‘/mysql//pid’
mkdir: created directory ‘/mysql//data’
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mkdir -pv /mysql/{3306,3307,3308}/{etc,socket,log,pid,data}  #别分创建各个实例对应文件存储路径,目录最好见名知意。

[root@node105.yinzhengjie.org.cn ~]# tree /mysql/        #查看咱们创建的目录结构
/mysql/
├── 3306          #用于开放3306端口的,以下3个目录功能雷同。
│   ├── data        #用于存储数据
│   ├── etc        #用于存储配置文件
│   ├── log        #用于存储日志文件
│   ├── pid        #用于存储进程的PID文件
│   └── socket       #用于存储本地连接的socket文件
├──
│   ├── data
│   ├── etc
│   ├── log
│   ├── pid
│   └── socket
└──
├── data
├── etc
├── log
├── pid
└── socket directories, files
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]#

2>.创建实例对应的数据库文件

[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ll /mysql//data/
total
[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mysql//data #创建3306实例的数据库文件
Installing MariaDB/MySQL system tables in '/mysql/3306/data' ...
-- :: [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
-- :: [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: : Table 'mysql.gtid_sla
ve_pos' doesn't existOK To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h node105.yinzhengjie.org.cn password 'new-password' Alternatively you can run:
'./bin/mysql_secure_installation' which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions. You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/mysql/3306/data' You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/ [root@node105.yinzhengjie.org.cn /usr/local/mysql]#
[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ll /mysql//data/
total
-rw-rw---- mysql mysql Oct : aria_log.
-rw-rw---- mysql mysql Oct : aria_log_control
-rw-rw---- mysql mysql Oct : ib_buffer_pool
-rw-rw---- mysql mysql Oct : ibdata1
-rw-rw---- mysql mysql Oct : ib_logfile0
-rw-rw---- mysql mysql Oct : ib_logfile1
drwx------ mysql root Oct : mysql
-rw-rw---- mysql mysql Oct : mysql-bin.
-rw-rw---- mysql mysql Oct : mysql-bin.index
-rw-rw---- mysql mysql Oct : mysql-bin.state
drwx------ mysql mysql Oct : performance_schema
drwx------ mysql root Oct : test
[root@node105.yinzhengjie.org.cn /usr/local/mysql]#

[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mysql/3306/data   #创建3306实例的数据库文件

[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ll /mysql//data/
total
[root@node105.yinzhengjie.org.cn /usr/local/mysql]#
[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mysql//data
Installing MariaDB/MySQL system tables in '/mysql/3307/data' ...
-- :: [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
-- :: [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: : Table 'mysql.gtid_sla
ve_pos' doesn't existOK To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h node105.yinzhengjie.org.cn password 'new-password' Alternatively you can run:
'./bin/mysql_secure_installation' which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions. You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/mysql/3307/data' You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/ [root@node105.yinzhengjie.org.cn /usr/local/mysql]#
[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ll /mysql//data/
total
-rw-rw---- mysql mysql Oct : aria_log.
-rw-rw---- mysql mysql Oct : aria_log_control
-rw-rw---- mysql mysql Oct : ib_buffer_pool
-rw-rw---- mysql mysql Oct : ibdata1
-rw-rw---- mysql mysql Oct : ib_logfile0
-rw-rw---- mysql mysql Oct : ib_logfile1
drwx------ mysql root Oct : mysql
-rw-rw---- mysql mysql Oct : mysql-bin.
-rw-rw---- mysql mysql Oct : mysql-bin.index
-rw-rw---- mysql mysql Oct : mysql-bin.state
drwx------ mysql mysql Oct : performance_schema
drwx------ mysql root Oct : test
[root@node105.yinzhengjie.org.cn /usr/local/mysql]#

[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mysql/3307/data

[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ll /mysql//data/
total
[root@node105.yinzhengjie.org.cn /usr/local/mysql]#
[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mysql//data
Installing MariaDB/MySQL system tables in '/mysql/3308/data' ...
-- :: [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
-- :: [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: : Table 'mysql.gtid_sla
ve_pos' doesn't existOK To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h node105.yinzhengjie.org.cn password 'new-password' Alternatively you can run:
'./bin/mysql_secure_installation' which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions. You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/mysql/3308/data' You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/ [root@node105.yinzhengjie.org.cn /usr/local/mysql]#
[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ll /mysql//data/
total
-rw-rw---- mysql mysql Oct : aria_log.
-rw-rw---- mysql mysql Oct : aria_log_control
-rw-rw---- mysql mysql Oct : ib_buffer_pool
-rw-rw---- mysql mysql Oct : ibdata1
-rw-rw---- mysql mysql Oct : ib_logfile0
-rw-rw---- mysql mysql Oct : ib_logfile1
drwx------ mysql root Oct : mysql
-rw-rw---- mysql mysql Oct : mysql-bin.
-rw-rw---- mysql mysql Oct : mysql-bin.index
-rw-rw---- mysql mysql Oct : mysql-bin.state
drwx------ mysql mysql Oct : performance_schema
drwx------ mysql root Oct : test
[root@node105.yinzhengjie.org.cn /usr/local/mysql]#

[root@node105.yinzhengjie.org.cn /usr/local/mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mysql/3308/data

3>.自定义MySQL各个实例的配置文件

[root@node105.yinzhengjie.org.cn ~]# cat /mysql//etc/my.cnf       #自定义MySQL实例的配置文件
[mysqld]
port =
datadir = /mysql//data
socket = /mysql//socket/mysql.sock [mysqld_safe]
log-error = /mysql//log/mariadb.log
pid-file = /mysql//pid/mariadb.pid
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3306/etc/my.cnf       #自定义MySQL实例的配置文件

[root@node105.yinzhengjie.org.cn ~]# cat /mysql//etc/my.cnf
[mysqld]
port =
datadir = /mysql//data
socket = /mysql//socket/mysql.sock [mysqld_safe]
log-error = /mysql//log/mariadb.log
pid-file = /mysql//pid/mariadb.pid
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3307/etc/my.cnf

[root@node105.yinzhengjie.org.cn ~]# cat /mysql//etc/my.cnf
[mysqld]
port =
datadir = /mysql//data
socket = /mysql//socket/mysql.sock [mysqld_safe]
log-error = /mysql//log/mariadb.log
pid-file = /mysql//pid/mariadb.pid
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3308/etc/my.cnf

4>.自定义MySQL各个实例的启动脚本

[root@node105.yinzhengjie.org.cn ~]# cat /mysql//mysqld
#!/bin/bash
#********************************************************************
#Author: YinZhengjie
#Email: y1053419035@qq.com
#Blog: https://www.cnblogs.com/yinzhengjie/
#Description: mysql start script
#******************************************************************** port=
mysql_user="root"
mysql_pwd="yinzhengjie"
cmd_path="/usr/local/mysql/bin"
mysql_basedir="/mysql"
mysql_sock="${mysql_basedir}/${port}/socket/mysql.sock" function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL...\n"
${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf &> /dev/null &
else
printf "MySQL is running...\n"
exit
fi
} function_stop_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "MySQL is stopped...\n"
exit
else
printf "Stoping MySQL...\n"
${cmd_path}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown
fi
} function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep
function_start_mysql
} case $ in
start)
function_start_mysql
;;
stop)
function_stop_mysql
;;
restart)
function_restart_mysql
;;
*)
printf "Usage: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3306/mysqld

[root@node105.yinzhengjie.org.cn ~]# cat /mysql//mysqld
#!/bin/bash
#********************************************************************
#Author: YinZhengjie
#Email: y1053419035@qq.com
#Blog: https://www.cnblogs.com/yinzhengjie/
#Description: mysql start script
#******************************************************************** port=
mysql_user="root"
mysql_pwd="yinzhengjie"
cmd_path="/usr/local/mysql/bin"
mysql_basedir="/mysql"
mysql_sock="${mysql_basedir}/${port}/socket/mysql.sock" function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL...\n"
${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf &> /dev/null &
else
printf "MySQL is running...\n"
exit
fi
} function_stop_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "MySQL is stopped...\n"
exit
else
printf "Stoping MySQL...\n"
${cmd_path}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown
fi
} function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep
function_start_mysql
} case $ in
start)
function_start_mysql
;;
stop)
function_stop_mysql
;;
restart)
function_restart_mysql
;;
*)
printf "Usage: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3307/mysqld

[root@node105.yinzhengjie.org.cn ~]# cat /mysql//mysqld
#!/bin/bash
#********************************************************************
#Author: YinZhengjie
#Email: y1053419035@qq.com
#Blog: https://www.cnblogs.com/yinzhengjie/
#Description: mysql start script
#******************************************************************** port=
mysql_user="root"
mysql_pwd="yinzhengjie"
cmd_path="/usr/local/mysql/bin"
mysql_basedir="/mysql"
mysql_sock="${mysql_basedir}/${port}/socket/mysql.sock" function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL...\n"
${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf &> /dev/null &
else
printf "MySQL is running...\n"
exit
fi
} function_stop_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "MySQL is stopped...\n"
exit
else
printf "Stoping MySQL...\n"
${cmd_path}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown
fi
} function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep
function_start_mysql
} case $ in
start)
function_start_mysql
;;
stop)
function_stop_mysql
;;
restart)
function_restart_mysql
;;
*)
printf "Usage: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3308/mysqld

[root@node105.yinzhengjie.org.cn ~]# chmod +x /mysql//mysqld     #别忘记给各个MySQL实例的启动脚本添加执行权限。
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# chmod +x /mysql//mysqld
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# chmod +x /mysql//mysqld

5>.启动mysql各个实例

[root@node105.yinzhengjie.org.cn ~]# ll /mysql/
total
drwxr-xr-x mysql root Oct :
drwxr-xr-x root root Oct :
drwxr-xr-x root root Oct :
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# chown mysql:mysql /mysql/ -R      #将所有实例的目录权限归属于mysql用户
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# ll /mysql/
total
drwxr-xr-x mysql mysql Oct :
drwxr-xr-x mysql mysql Oct :
drwxr-xr-x mysql mysql Oct :
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# ll /mysql//
total
drwxr-xr-x mysql mysql Oct : data
drwxr-xr-x mysql mysql Oct : etc
drwxr-xr-x mysql mysql Oct : log
-rw-r--r-- mysql mysql Oct : mysqld
drwxr-xr-x mysql mysql Oct : socket
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# ll /mysql//etc/
total
-rw-r--r-- mysql mysql Oct : my.cnf
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# chown mysql:mysql /mysql/ -R      #将所有实例的目录权限归属于mysql用户

[root@node105.yinzhengjie.org.cn ~]# /mysql//mysqld start        #启动MySQL的3306实例,下面并分别启动3307和3308实例
Starting MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# /mysql//mysqld start
Starting MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# /mysql//mysqld start
Starting MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# ss -ntl                  #检查对应的端口号
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
[root@node105.yinzhengjie.org.cn ~]#

6>.连接各个实例检查服务是否运行正常

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -p -S /mysql//socket/mysql.sock     #使用指定的套接字连接。
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.2.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SELECT @@port;      #检查当前实例的运行端口
+--------+
| @@port |
+--------+
| |
+--------+
row in set (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.-MariaDB, for Linux (x86_64) using readline 5.1 Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.-MariaDB MariaDB Server
Protocol version:
Connection: Localhost via UNIX socket      #注意这里的提示是基于套接字连接的,当然我们也可以基于IP地址的方式连接。
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /mysql//socket/mysql.sock
Uptime: min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.022
-------------- MariaDB [(none)]> QUIT
Bye
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -p -h 127.0.0.1 -P       #基于IP地址的方式连接MySQL
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.2.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SELECT @@port;
+--------+
| @@port |
+--------+
| |
+--------+
row in set (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.-MariaDB, for Linux (x86_64) using readline 5.1 Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.-MariaDB MariaDB Server
Protocol version:
Connection: 127.0.0.1 via TCP/IP      #当前连接状态是基于TCP/IP协议连接的。
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
TCP port:
Uptime: min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.013
-------------- MariaDB [(none)]>
MariaDB [(none)]>

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -p -h 127.0.0.1 -P 3307      #基于IP地址的方式连接MySQL

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -p  -S /mysql//socket/mysql.sock -P     #连接MySQL的3308实例
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.2.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SELECT @@port;
+--------+
| @@port |
+--------+
| |
+--------+
row in set (0.00 sec) MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.-MariaDB, for Linux (x86_64) using readline 5.1 Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.-MariaDB MariaDB Server
Protocol version:
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /mysql//socket/mysql.sock
Uptime: min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.010
-------------- MariaDB [(none)]> quit
Bye
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -p -S /mysql/3308/socket/mysql.sock -P 3308    #连接MySQL的3308实例

7>.为各个MySQL实例进行安全初始化

[root@node105.yinzhengjie.org.cn ~]# mysql_secure_installation -S /mysql//socket/mysql.sock     #为3306实例修改数据库密码

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none):
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation. Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success! By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y
... Success! By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB
installation should now be secure. Thanks for using MariaDB!
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mysql_secure_installation -S /mysql/3306/socket/mysql.sock     #为3306实例修改数据库密码

[root@node105.yinzhengjie.org.cn ~]# mysql_secure_installation -S /mysql//socket/mysql.sock      #为3307实例修改数据库密码

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none):
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation. Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success! By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y
... Success! By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB
installation should now be secure. Thanks for using MariaDB!
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mysql_secure_installation -S /mysql/3307/socket/mysql.sock      #为3307实例修改数据库密码

[root@node105.yinzhengjie.org.cn ~]# mysql_secure_installation -S /mysql//socket/mysql.sock       #为3308实例修改数据库密码

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none):
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation. Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success! By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y
... Success! By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB
installation should now be secure. Thanks for using MariaDB!
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mysql_secure_installation -S /mysql/3308/socket/mysql.sock       #为3308实例修改数据库密码

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot   -h 127.0.0.1 -P  -pyinzhengjie
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.2.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SELECT user,password,host FROM mysql.user;    #很显然,匿名用户被删除而且root用户被加密啦~
+------+-------------------------------------------+-----------+
| user | password | host |
+------+-------------------------------------------+-----------+
| root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | localhost |
| root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | 127.0.0.1 |
| root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | :: |
+------+-------------------------------------------+-----------+
rows in set (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.-MariaDB, for Linux (x86_64) using readline 5.1 Connection id:
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.-MariaDB MariaDB Server
Protocol version:
Connection: 127.0.0.1 via TCP/IP          #当前连接基于TCP/IP协议连接的
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
TCP port:
Uptime: min sec Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.058
-------------- MariaDB [(none)]>

8>.停止MySQL服务

[root@node105.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# /mysql//mysqld stop
Stoping MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# /mysql//mysqld stop
Stoping MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# /mysql//mysqld stop
Stoping MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN ::: :::*
[root@node105.yinzhengjie.org.cn ~]#

9>.注意事项

  MySQL启动脚本很方便管理多实例,给我们带来方便的同时在安全性上却打了大大的折扣,细心的小伙伴如果看了我上面的启动脚本会发现mysql数据库root用户的密码被暴漏了。推荐为脚本文件修改权限为700且仅有root用户方能调用。

  我们也可以为脚本添加开机自启动,需要把启动脚本放在"/etc/init.d"目录中,但是脚本文件得添加类似"chkconfig: 123 70 3"的行注释,否则会抛出"... does not support chkconfig"的字样。

  无论你的MySQL程序基于哪种方式安装,关于MySQL不同版本实例的实战参考本篇博客即可,当然你也可以使用MySQL官网提供的"mysqld_mutl"(要求版本相同)工具来实现多实例配置。
[root@node105.yinzhengjie.org.cn ~]# mysqld_multi --help            #查看多实例脚本的帮助信息
mysqld_multi version 2.20 by Jani Tolonen Description:
mysqld_multi can be used to start, or stop any number of separate
mysqld processes running in different TCP/IP ports and UNIX sockets. mysqld_multi can read group [mysqld_multi] from my.cnf file. You may
want to put options mysqld=... and mysqladmin=... there. Since
version 2.10 these options can also be given under groups [mysqld#],
which gives more control over different versions. One can have the
default mysqld and mysqladmin under group [mysqld_multi], but this is
not mandatory. Please note that if mysqld or mysqladmin is missing
from both [mysqld_multi] and [mysqld#], a group that is tried to be
used, mysqld_multi will abort with an error. mysqld_multi will search for groups named [mysqld#] from my.cnf (or
the given --defaults-extra-file=...), where '#' can be any positive
integer starting from . These groups should be the same as the regular
[mysqld] group, but with those port, socket and any other options
that are to be used with each separate mysqld process. The number
in the group name has another function; it can be used for starting,
stopping, or reporting any specific mysqld server. Usage: mysqld_multi [OPTIONS] {start|stop|report} [GNR,GNR,GNR...]
or mysqld_multi [OPTIONS] {start|stop|report} [GNR-GNR,GNR,GNR-GNR,...] The GNR means the group number. You can start, stop or report any GNR,
or several of them at the same time. (See --example) The GNRs list can
be comma separated or a dash combined. The latter means that all the
GNRs between GNR1-GNR2 will be affected. Without GNR argument all the
groups found will either be started, stopped, or reported. Note that
syntax for specifying GNRs must appear without spaces. Options: These options must be given before any others:
--no-defaults Do not read any defaults file
--defaults-file=... Read only this configuration file, do not read the
standard system-wide and user-specific files
--defaults-extra-file=... Read this configuration file in addition to the
standard system-wide and user-specific files
Using: --example Give an example of a config file with extra information.
--help Print this help and exit.
--log=... Log file. Full path to and the name for the log file. NOTE:
If the file exists, everything will be appended.
Using:
--mysqladmin=... mysqladmin binary to be used for a server shutdown.
Since version 2.10 this can be given within groups [mysqld#]
Using:
--mysqld=... mysqld binary to be used. Note that you can give mysqld_safe
to this option also. The options are passed to mysqld. Just
make sure you have mysqld in your PATH or fix mysqld_safe.
Using:
Please note: Since mysqld_multi version 2.3 you can also
give this option inside groups [mysqld#] in ~/.my.cnf,
where '#' stands for an integer (number) of the group in
question. This will be recognised as a special option and
will not be passed to the mysqld. This will allow one to
start different mysqld versions with mysqld_multi.
--no-log Print to stdout instead of the log file. By default the log
file is turned on.
--password=... Password for mysqladmin user.
--silent Disable warnings.
--tcp-ip Connect to the MariaDB server(s) via the TCP/IP port instead
of the UNIX socket. This affects stopping and reporting.
If a socket file is missing, the server may still be
running, but can be accessed only via the TCP/IP port.
By default connecting is done via the UNIX socket.
--user=... mysqladmin user. Using: root
--verbose Be more verbose.
--version Print the version number and exit.
--wsrep-new-cluster Bootstrap a cluster.
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# mysqld_multi --help            #查看多实例脚本的帮助信息

三.为MySQL实例设置默认字符集为utf8mb4

1>.修改服务端字符集

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie -S /mysql/3306/socket/mysql.sock     
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.19-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> STATUS      
--------------
mysql Ver 15.1 Distrib 10.2.19-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 10
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.19-MariaDB MariaDB Server
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /mysql/3306/socket/mysql.sock
Uptime: 3 hours 29 min 26 sec Threads: 8 Questions: 120 Slow queries: 0 Opens: 41 Flush tables: 1 Open tables: 33 Queries per second avg: 0.009
-------------- MariaDB [(none)]>
MariaDB [(none)]> QUIT
Bye
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# vim /mysql/3306/etc/my.cnf
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3306/etc/my.cnf    #需要在"[mysqld]"添加"character-set-server"属性
[mysqld]
character-set-server=utf8mb4
port = 3306
datadir = /mysql/3306/data
socket = /mysql/3306/socket/mysql.sock [mysqld_safe]
log-error = /mysql/3306/log/mariadb.log
pid-file = /mysql/3306/pid/mariadb.pid [root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# /mysql/3306/mysqld restart
Restarting MySQL...
Stoping MySQL...
Starting MySQL...
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie -S /mysql/3306/socket/mysql.sock
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.19-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.19-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.19-MariaDB MariaDB Server
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /mysql/3306/socket/mysql.sock
Uptime: 3 sec Threads: 7 Questions: 4 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 1.333
-------------- MariaDB [(none)]> quit
Bye
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# cat /mysql/3306/etc/my.cnf    #需要在"[mysqld]"添加"character-set-server"属性

2>.修改客户端字符集

[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie -S /mysql/3306/socket/mysql.sock
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.2.19-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.19-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 9
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.19-MariaDB MariaDB Server
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /mysql/3306/socket/mysql.sock
Uptime: 52 sec Threads: 7 Questions: 8 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 0.153
-------------- MariaDB [(none)]> QUIT
Bye
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# vim /etc/my.cnf.d/mysql-clients.cnf
[root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# grep -v ^# /etc/my.cnf.d/mysql-clients.cnf     #修改客户端的默认字符集 [mysql]
default-character-set=utf8mb4 [mysql_upgrade] [mysqladmin] [mysqlbinlog] [mysqlcheck] [mysqldump] [mysqlimport] [mysqlshow] [mysqlslap] [root@node105.yinzhengjie.org.cn ~]#
[root@node105.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie -S /mysql/3306/socket/mysql.sock
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.19-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
MariaDB [(none)]> STATUS
--------------
mysql Ver 15.1 Distrib 10.2.19-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 10
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.2.19-MariaDB MariaDB Server
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /mysql/3306/socket/mysql.sock
Uptime: 2 min 28 sec Threads: 7 Questions: 12 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 0.081
-------------- MariaDB [(none)]>
MariaDB [(none)]> EXIT
Bye
[root@node105.yinzhengjie.org.cn ~]#

[root@node105.yinzhengjie.org.cn ~]# grep -v ^# /etc/my.cnf.d/mysql-clients.cnf     #修改客户端的默认字符集

Mariadb/MySQL多实例实战的更多相关文章

  1. CentOS7.7下二进制部署MySQL多版本多实例实战

    第一章 需求说明 部署MySQL5.7的三个多实例环境(端口分别为3307,3308,3309) 部署MySQL5.6和8.0版本数据库实例((端口分别为3316和3326) 第二章 环境准备 1.虚 ...

  2. mysql 多实例案例实战

    其实Mysql多实例就是在一个 mysql 服务上面启动三个实例,相当于三个分离开来的数据库,至于为什么要做这个,你也可以选择分别安装三个MySQL,只是过于麻烦,多实例中只需要一个配置档my.cnf ...

  3. mysql多实例的配置和管理

    原文地址:mysql多实例的配置和管理 作者:飞鸿无痕 多实例mysql的安装和管理 mysql的多实例有两种方式可以实现,两种方式各有利弊.第一种是使用多个配置文件启动不同的进程来实现多实例,这种方 ...

  4. (MariaDB/MySQL)之DML(1):数据插入

    本文目录: 1.insert和replace插入数据 1.1 insert into values() 1.2 insert into set 1.3 insert into select_state ...

  5. MariaDB/MySQL用户和权限管理

    本文目录: 1.权限验证 1.1 权限表 1.2 图解认证和权限分配的两个阶段 1.3 权限生效时机 2.用户管理 2.1 创建用户 2.2 create user和alter user 2.3 记录 ...

  6. MariaDB/MySQL备份和恢复(二):数据导入、导出

    MariaDB/MySQL备份恢复系列: 备份和恢复(一):mysqldump工具用法详述 备份和恢复(二):导入.导出表数据 备份和恢复(三):xtrabackup用法和原理详述 1.导出.导入数据 ...

  7. MySQL高性能优化实战总结!

    1.1 前言 MySQL对于很多Linux从业者而言,是一个非常棘手的问题,多数情况都是因为对数据库出现问题的情况和处理思路不清晰.在进行MySQL的优化之前必须要了解的就是MySQL的查询过程,很多 ...

  8. Mysql多实例添加到开机自启的方法

    Mysql多实例配置成功后,想让配置成开机自启. 首先看一下Linux启动的知识点,顺序如下. 1 加载内核2 执行init程序3 /etc/rc.d/rc.sysinit   # 由init执行的第 ...

  9. MySQL多实例(二)

    一.多实例MySQL数据库原理 1.1:原理图 1.2:多实例原理(什么是多实例) 简单来说MySQL多实例就是在一台服务器上同时开启多个不用的服务端口(如:3306.3307),同时运行多个MySQ ...

随机推荐

  1. Kubernetes之使用kubeadm部署

    参考:https://www.cnblogs.com/caoxb/p/11243472.html 部署虚拟机规划 192.168.1.11 k8s-master 192.168.1.12 k8s-no ...

  2. RubyGem镜像/ruby国内镜像

    RubyGem 网上推荐的淘宝的镜像已经无法访问 清华镜像 # 添加 TUNA 源并移除默认源 gem sources --add https://mirrors.tuna.tsinghua.edu. ...

  3. Java Web 应用概述

    1.java Web 应用是建立在java语言基础上的企业web应用系统,oracle公司根据行业发展和便于开发制定了一套规范:Java EE规范,截至到当前(2016.3.11)是java EE7规 ...

  4. 视频质量诊断----PTZ云台运动检测

    一.PTZ云台运动检测是通过配合云台运动的功能检测云台运动是否正常. 二.原理 取云台运动前N帧图像,进行背景建模,得到运动前背景A. 设备发送云台运动指令,让云台进行运动,改变场景. 取云台运动后N ...

  5. webapi+swagger ui 文档描述

    代码:GitHub swagger ui在我们的.NET CORE和.NET Framework中的展现形式是不一样的,如果有了解的,在.NET CORE中的是比.NET Framework好的.两张 ...

  6. jdk安装配置(不适合新人,个人随笔)

    jdk下载:https://www.oracle.com/technetwork/java/javase/downloads/index.html 按个人喜好下载相应版本,一般比最新的低一个版本 下载 ...

  7. c#中特性Attribute

    接上篇: 特性介绍: 特性是一个类,需要间接或者直接继承Attribute父类,在标记特性时以中括号包裹,可以标记在元素之前.AttributeTargets.Class设置标记的元素,需要明确指定标 ...

  8. linux配置ssh免密钥登录

    https://blog.csdn.net/xiaoyi23000/article/details/80597516 1.执行命令ssh-keygen -t rsa,生成公钥和私钥 2.会在当前用户的 ...

  9. Delphi TButton.OnClick 匿名函数用法

    type TNotifyEventRef = reference to procedure(Sender: TObject); function AnonymousEvent(const Proc: ...

  10. Java8 集合相关操作

    // java8 集合快速转成string List<String> cities; String citiesCommaSeparated = String.join(",&q ...