一、mysql安装

1、下载mysql数据库源码包:

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

2、安装mysql环境安装和运行所依赖的库文件:

[root@mysqldb1 ~]# yum install gcc gcc-c++  ncurses ncurses-devel  bison cmake -y

2.1、添加mysql系统用户:

[root@mysqldb1 ~]# useradd mysql -M -r -s /sbin/nologin

3、解压mysql源码包:

[root@mysqldb1 ~]# tar xf mysql-5.6.27.tar.gz

[root@mysqldb1 ~]# ls

anaconda-ks.cfg  install.log  install.log.syslog  mysql-5.6.27  mysql-5.6.27.tar.gz

[root@mysqldb1 ~]# cd mysql-5.6.27

[root@mysqldb1 mysql-5.6.27]# ls

BUILD           configure.cmake      INSTALL-SOURCE      mysql-test  scripts        tests

BUILD-CMAKE     COPYING              INSTALL-WIN-SOURCE  mysys       sql            unittest

client          dbug                 libevent            mysys_ssl   sql-bench      VERSION

cmake           Docs                 libmysql            packaging   sql-common     vio

CMakeLists.txt  Doxyfile-perfschema  libmysqld           plugin      storage        win

cmd-line-utils  extra                libservices         README      strings        zlib

config.h.cmake  include              man                 regex       support-files

4、配置mysql安装参数,并生成MakeFile及cmake编译时所需要配置文件文件:

[root@mysqldb1 mysql-5.6.27]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6.27 \

-DMYSQL_DATADIR=/usr/local/mysql5.6.27/data \

-DMYSQL_UNIX_ADDR=/usr/local/mysql5.6.27/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 \

-DWITH_FAST_MUTEXES=1 \

-DWITH_ZLIB=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_DEBUG=0

4.1执行cmake后新增或修改过的文件如下所示:

[root@mysqldb1 mysql-5.6.27]# ll | grep root

-rw-r--r--.  1 root root   55401 Oct 18 20:57 CMakeCache.txt

drwxr-xr-x. 12 root root    4096 Oct 18 20:58 CMakeFiles

-rw-r--r--.  1 root root    7421 Oct 18 20:57 cmake_install.cmake

-rw-r--r--.  1 root root    4767 Oct 18 20:57 CPackConfig.cmake

-rw-r--r--.  1 root root    5662 Oct 18 20:57 CPackSourceConfig.cmake

-rw-r--r--.  1 root root    1607 Oct 18 20:57 CTestTestfile.cmake

-rw-r--r--.  1 root root    6628 Oct 18 20:57 info_macros.cmake

-rw-r--r--.  1 root root    6375 Oct 18 20:57 make_dist.cmake

-rw-r--r--.  1 root root   69001 Oct 18 20:57 Makefile

drwxr-xr-x.  2 root root    4096 Oct 18 20:57 source_downloads

-rw-r--r--.  1 root root      88 Oct 18 20:56 VERSION.dep

5、根据cmake生成的配置文件编译及安装mysql数据库

[root@mysqldb1 mysql-5.6.27]# make && make install

…… ……

5.1、除了 CMAKE_INSTALL_PREFIX 之外,CMake 所产生出来的 Makefile 也支援 DESTDIR。有下面两种使用方式:

cmake .

make install DESTDIR="/usr/local/mysql5.6.27"

export DESTDIR="/usr/local/mysql5.6.27"

make install

[root@mysqldb1 mysql-5.6.27]# echo $?

0

6、修改mysql配置文件:

[root@mysqldb1 mysql-5.6.27]# cd /usr/local/mysql5.6.27/

[root@mysqldb1 mysql5.6.27]# ls

bin  COPYING  data  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  scripts  share  sql-bench  support-files

[root@mysqldb1 mysql5.6.27]# cd support-files/

[root@mysqldb1 support-files]# ls

binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server

[root@mysqldb1 support-files]# cp my-default.cnf ../my.cnf

[root@mysqldb1 support-files]# cd ..

[root@mysqldb1 mysql5.6.27]# ls

bin  COPYING  data  docs  include  INSTALL-BINARY  lib  man  my.cnf  mysql-test  README  scripts  share  sql-bench  support-files

[root@mysqldb1 mysql5.6.27]# vim my.cnf

1 # For advice on how to change settings please see

2 # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

3 # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

4 # *** default location during install, and will be replaced if you

5 # *** upgrade to a newer version of MySQL.

6

7 [mysqld]

8

9 # Remove leading # and set to the amount of RAM for the most important data

10 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

11 # innodb_buffer_pool_size = 128M

12

13 # Remove leading # to turn on a very important data integrity option: logging

14 # changes to the binary log between backups.

15 # log_bin

16

17 # These are commonly set, remove the # and set as required.

18 # basedir = .....

19 # datadir = .....

20 # port = .....

21 # server_id = .....

22 # socket = .....

23

24 # Remove leading # to set options mainly useful for reporting servers.

25 # The server defaults are faster for transactions and fast SELECTs.

26 # Adjust sizes as needed, experiment to find the optimal values.

27 # join_buffer_size = 128M

28 # sort_buffer_size = 2M

29 # read_rnd_buffer_size = 2M

30

31 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

把my.cnf中的 18、19、20 改成以下内容:

18 basedir = /usr/local/mysql5.6.27

19 datadir = /usr/local/mysql5.6.27/data

20 port = 3306

7、修改mysql数据目录的用户使用权限:

[root@mysqldb1 mysql5.6.27]# chown mysql.mysql -R data/

8、执行mysql数据库数据字典安装文件脚本:

[root@mysqldb1 mysql5.6.27]# scripts/mysql_install_db --user=mysql  --defaults-file=/usr/local/mysql5.6.27/my.cnf

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

#8.1、设置mysql用户的密码:

./bin/mysqladmin -u root password 'new-password'

./bin/mysqladmin -u root -h mysqldb1 password 'new-password'

Alternatively you can run:

#8.2、交互式设置mysql用户的密码:

./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 manual for more instructions.

You can start the MySQL daemon with:

#8.3、启动mysql服务器:

cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

#8.4执行mysql脚本测试mysql是否启动成功:

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file ./my.cnf on the system.

Because this file might be in use, it was not replaced,

but was used in bootstrap (unless you used --defaults-file)

and when you later start the server.

The new default config file was created as ./my-new.cnf,

please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

--defaults-file argument to mysqld_safe when starting the server

9、启动mysql服务

[root@mysqldb1 mysql5.6.27]# bin/mysqld_safe --defaults-file=/usr/local/mysql5.6.27/my.cnf --user=mysql >/dev/null &

[1] 41074

9.1、测试MySQL服务是否启动

[root@mysqldb1 mysql5.6.27]# lsof -i :3306

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

mysqld  41201 mysql   10u  IPv6 100814      0t0  TCP *:mysql (LISTEN)

[root@mysqldb1 mysql5.6.27]# netstat -tulnp | grep 3306

tcp        0      0 :::3306                     :::*                        LISTEN      41201/mysqld

10、设置MySQL用户密码

10.1、交互式设置:

[root@mysqldb1 mysql5.6.27]# ./bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user.  If you've just installed MySQL, 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 MySQL

root user without the proper authorisation.

Set root password? [Y/n] y #是否设置root用户密码

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL 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     #是否删除mysql匿名用户

... 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] n #是否容许mysql管理员root用户远程登录

... skipping.

By default, MySQL 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 #是否移除test数据库

- 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  #是否重新加载权限表,相当于flush privileges;

... Success!

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

Cleaning up...

10.2、用非交互式命令mysqladmin管理工具修改密码

[root@mysqldb1 mysql5.6.27]# ./bin/mysqladmin -u root -p123456 password '654321'

Warning: Using a password on the command line interface can be insecure.

11、把mysql的相关命令添加到环境变量里:

[root@mysqldb1 mysql5.6.27]# echo PATH=/usr/local/mysql5.6.27/bin/:$PATH >> /etc/profile

[root@mysqldb1 mysql5.6.27]# source  /etc/profile

12、用mysql客户端命令登录mysql服务器

[root@mysqldb1 mysql5.6.27]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 13

Server version: 5.6.27 Source distribution

Copyright (c) 2000, 2015, 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; #显示root用户可以管理的数据库管理系统中有数据库

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.08 sec)

mysql> use mysql; #切换进入mysql数据库

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables; #查看mysql数据库中有多少数据表文件

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| innodb_index_stats        |

| innodb_table_stats        |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slave_master_info         |

| slave_relay_log_info      |

| slave_worker_info         |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

28 rows in set (0.00 sec)

mysql> select host,user,password from user;      #查看数据库的中用户

+-----------+------+-------------------------------------------+

| host      | user | password                                  |

+-----------+------+-------------------------------------------+

| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| mysqldb1  | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| 127.0.0.1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| ::1       | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

+-----------+------+-------------------------------------------+

4 rows in set (0.00 sec)

13、制作开机自启动服务:

13.1、#把安装路劲下的support-files/mysql.server文件到改名为/etc/init.d/mysqld

[root@mysqldb1 mysql5.6.27]# cd support-files/

[root@mysqldb1 support-files]# cp mysql.server /etc/init.d/mysqld

13.2、查看mysqld是否具有执行权限:

[root@mysqldb1 support-files]# ll /etc/init.d/mysqld

-rwxr-xr-x. 1 root root 10916 Oct 18 23:04 /etc/init.d/mysqld

13.3、给mysql服务添加开机自启动:

[root@mysqldb1 support-files]# chkconfig --add mysqld

13.4、查看mysql服务运行级别:

[root@mysqldb1 support-files]# chkconfig --list mysqld

mysqld          0:off 1:off 2:on 3:on 4:on 5:on 6:off

13.5、修改mysql运行级别:

[root@mysqldb1 support-files]# chkconfig --level 24 mysqld off

[root@mysqldb1 support-files]# chkconfig --list mysqld

mysqld          0:off 1:off 2:off 3:on 4:off 5:on 6:off

13.6、返回上级目录并把目录下mysql配置文件my.cnf复制到 /etc目录下,并重新启动mysql服务:

[root@mysqldb1 support-files]# cd ..

[root@mysqldb1 mysql5.6.27]# cp my.cnf /etc/my.cnf

cp: overwrite `/etc/my.cnf'? y

[root@mysqldb1 mysql5.6.27]# service mysqld restart #重启mysql服务

Shutting down MySQL..                                      [  OK  ]

Starting MySQL..                                           [  OK  ]

[1]+  Done                    bin/mysqld_safe --defaults-file=/usr/local/mysql5.6.27/my.cnf --user=mysql > /dev/null

14、用管理员账户登录mysql并修改mysql用户密码:

这种方式必须是先用root帐户登入mysql,然后执行:

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root';

Query OK, 1 row affected (0.00 sec)

Rows matched: 4  Changed: 1  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| root | mysqldb1  | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| root | ::1       | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

+------+-----------+-------------------------------------------+

4 rows in set (0.00 sec)

二、mysql多实例实现:

1、mysql多实例的原理

mysql多实例,简单的说,就是在一台服务器上开启多个不同的mysql服务端口(如3306,3307),运行多个mysql服务进程。这些服务进程通过不同的socket监听不同的服务端口,来提供各自的服务。

这些mysql实例共用一套mysql安装程序,使用不同的my.cnf配置文件、启动程序、数据文件。在提供服务时,mysql多实例在逻辑上看来是各自独立的,各个实例之间根据配置文件的设定值,来取得服务器的相关硬件资源。

2、mysql多实例的特点

2.1 有效的利用服务器资源

当单个服务器资源有剩余时,可以充分利用剩余的服务器资源来提供更多的服务。

2.2 节约服务器资源

当公司资金紧张,但是数据库需要各自提供独立服务,而且需要主从同步等技术时,使用多实例就最好了。

2.3 出现资源互相抢占问题

当某个实例服务并发很高或者有慢查询时,会消耗服务器更多的内存、CPU、磁盘IO等资源,这时就会导致服务器上的其它实例提供访问的质量下降,出现服务器资源互相抢占的现象。

3、mysql多实例应用场景

3.1 资金紧张型公司的选择

当公司业务访问量不太大,又舍不得花钱,但同时又希望不同业务的数据库服务各自独立,而且需要主从同步进行等技术提供备份或读写分离服务时,使用多实例是最好不过的。

3.2 并发访问不是特别大的业务

当公司业务访问量不太大,服务器资源基本闲置的比较多,这是就很适合多实例的应用。如果对SQL语句优化的好,多实例是一个很值得使用的技术。即使并发很大,只要合理分配好系统资源,也不会有太大问题。

4、mysql5.5多实例部署方法

4.1 mysql5.5多实例部署方法

mysql5.5多实例部署方法一个是通过多个配置文件启动多个不同进程的方法,第二个是使用官方自带的mysqld_multi来实现。

第一种方法我们可以把各个实例的配置文件分开,管理比较方便。第二种方法就是把多个实例都放到一个配置文件中,这个管理不是很方便。所以在此我们选择第一种方法,而且以下实验我们全部是在此方法下进行的。

4.2 mysql5.5的安装及配置

要配置mysql5.5多实例,我们首先要安装mysql5.5,mysql5.5安装完毕后,我们不要启动mysql,因为此时mysql是单实例的。

5、使用多个配置文件启动多个不同进程:

这种架构是使用多个配置文件启动不同的进程来实现多实例,这种方式的优势逻辑简单,配置简单,缺点是管理起来不太方便,但相对独立,使mysql的耦合度降低了许多。

[root@mysqldb1 mysql]# mkdir -p /mysqldata/330{6,7,8}/

5.1、配置端口号为3306的mysql实例

5.1.1、配置3306的my.cnf文件

[root@mysqldb1 mysql5.6.27]# vim /mysqldata/3306/my.cnf

[client]

port = 3306

socket = /mysqldata/3306/mysql.sock

[mysqld]

datadir=/mysqldata/3306/

skip-name-resolve

lower_case_table_names=1

innodb_file_per_table=1

port = 3306

socket = /mysqldata/3306/mysql.sock

back_log = 50

max_connections = 300

max_connect_errors = 1000

table_open_cache = 2048

max_allowed_packet = 16M

binlog_cache_size = 2M

max_heap_table_size = 32M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 64

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 2M

ft_min_word_len = 4

default-storage-engine = innodb

thread_stack = 192K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 32M

log-bin=mysql-bin

binlog_format=mixed

slow_query_log

long_query_time = 1

server-id = 1

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 2M

bulk_insert_buffer_size = 32M

myisam_sort_buffer_size = 64M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

innodb_additional_mem_pool_size = 8M

innodb_buffer_pool_size = 100M

innodb_data_file_path = ibdata1:10M:autoextend

innodb_file_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 8M

innodb_log_file_size = 256M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

innodb_lock_wait_timeout = 120

[mysqldump]

quick

max_allowed_packet = 128M

[mysql]

no-auto-rehash

prompt=\\u@\\d \\R:\\m>

[myisamchk]

key_buffer_size = 256M

sort_buffer_size = 256M

read_buffer = 8M

write_buffer = 8M

[mysqlhotcopy]

interactive-timeout

[mysqld_safe]

open-files-limit = 1024

5.1.2、启动端口号为3306的实例并设置密码:

#安装端口号为3306的mysql实例:

[root@mysqldb1 mysql5.6.27]# /usr/local/mysql5.6.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.27 --datadir=/mysqldata/3306  --defaults-file=/mysqldata/3306/my.cnf

#启动端口号为3306的mysql实例:

[root@mysqldb1 mysqldata]# /usr/local/mysql5.6.27/bin/mysqld_safe --defaults-file=/mysqldata/3306/my.cnf 2>&1 > /dev/null &

[2] 5846

#给端口号为3306的mysql实例设置密码:

[root@mysqldb1 mysql5.6.27]# /usr/local/mysql5.6.27/bin/mysqladmin -uroot password '123456' -S /mysqldata/3306/mysql.sock

Warning: Using a password on the command line interface can be insecure.

#登陆端口号为3306的mysql实例服务器:

[root@mysqldb1 mysql5.6.27]# mysql -uroot -p123456 -S /mysqldata/3306/mysql.sock

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.6.27-log Source distribution

Copyright (c) 2000, 2015, 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>

5.1.3设置mysql的脚本启动文件:

[root@mysqldb1 mysql5.6.27]# vim /mysqldata/3306/mysqld

#!/bin/bash

mysql_port=3306

mysql_username="root"

mysql_password="123456"

function_start_mysql()

{

printf "Starting MySQL...\n"

/bin/sh /usr/local/mysql5.6.27/bin/mysqld_safe  --defaults-file=/mysqldata/${mysql_port}/my.cnf 2>&1 > /dev/null &

}

function_stop_mysql()

{

printf "Stoping MySQL...\n"

/usr/local/mysql5.6.27/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /mysqldata/${mysql_port}/mysql.sock shutdown

}

function_restart_mysql()

{

printf "Restarting MySQL...\n"

function_stop_mysql

function_start_mysql

}

function_kill_mysql()

{

kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')

kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')

}

case $1 in

start)

function_start_mysql;;

stop)

function_stop_mysql;;

kill)

function_kill_mysql;;

restart)

function_stop_mysql

function_start_mysql;;

*)

echo "Usage: /mysqldata/${mysql_port}/mysqld {start|stop|restart|kill}";;

esac

5.1.4、测试启动进程:

#启动端口号为3306的mysql

[root@mysqldb1 mysql5.6.27]# /mysqldata/3306/mysqld start

Starting MySQL...

[root@mysqldb1 mysql5.6.27]# netstat -tulnp | grep 3306

tcp        0      0 :::3306                     :::*                        LISTEN      46977/mysqld

#重启端口号为3306的mysql

[root@mysqldb1 mysql5.6.27]# /mysqldata/3306/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

[root@mysqldb1 mysql5.6.27]# netstat -tulnp | grep 3306

tcp        0      0 :::3306                     :::*                        LISTEN      47669/mysqld

#停止端口号为3306的mysql

[root@mysqldb1 mysql5.6.27]# /mysqldata/3306/mysqld stop

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

[root@mysqldb1 mysql5.6.27]# netstat -tulnp | grep 3306

5.2、配置端口号为3307、3308的mysql实例:

5.2.1、复制目录/mysqldata/3306下的配置文件my.cnf和启动脚本分别到 /mysqldata/3307 和 /mysqldata/3308 目录下

[root@mysqldb1 mysqldata]# cd /mysqldata/3306

[root@mysqldb1 3306]# cp my.cnf mysqld ../3307/

[root@mysqldb1 3306]# cp my.cnf mysqld ../3308/

5.2.3、分别修改端口号为3307、3308的配置文件和启动文件

[root@mysqldb1 3307]# cd ../3308

[root@mysqldb1 3308]# sed -i 's/3306/3308/g' mysqld

[root@mysqldb1 3308]# sed -i 's/3306/3308/g' my.cnf

[root@mysqldb1 3308]# sed -i 's/3306/3307/g' ../3307/my.cnf

[root@mysqldb1 3308]# sed -i 's/3306/3307/g' ../3307/mysqld

5.2.4、分别安装端口号为3307、3308的mysql实例数据库

#初始化端口号为3307的实例数据库:

[root@mysqldb1 3308]# /usr/local/mysql5.6.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.27 --datadir=/mysqldata/3307 --defaults-file=/mysqldata/3307/my.cnf

#初始化端口号为3308的实例数据库:

[root@mysqldb1 3308]# /usr/local/mysql5.6.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.27 --datadir=/mysqldata/3308 --defaults-file=/mysqldata/3308/my.cnf

5.2.5、分别启动端口号为3307、3308的mysql实例数据库

#启动端口号为3307的实例:

[root@mysqldb1 3308]# /usr/local/mysql5.6.27/bin/mysqld_safe  --defaults-file=/mysqldata/3307/my.cnf 2>&1 >/dev/null &

[1] 47969

#启动端口号为3308的实例:

[root@mysqldb1 3308]# /usr/local/mysql5.6.27/bin/mysqld_safe  --defaults-file=/mysqldata/3308/my.cnf 2>&1 >/dev/null &

[2] 48654

#查看mysql实例的启动情况:

[root@mysqldb1 3308]# netstat -tulnp | grep 330

tcp        0      0 :::3307                     :::*                        LISTEN      48632/mysqld

tcp        0      0 :::3308                     :::*                        LISTEN      49317/mysqld

5.2.6、分别修改端口号为3307、3308的mysql实例的管理员密码

#修改端口号为3307实例的管理员root用户的密码:

[root@mysqldb1 3308]# /usr/local/mysql5.6.27/bin/mysqladmin -uroot password '123456' -S /mysqldata/3307/mysql.sock

Warning: Using a password on the command line interface can be insecure.

#修改端口号为3308实例的管理员root用户的密码:

[root@mysqldb1 3308]# /usr/local/mysql5.6.27/bin/mysqladmin -uroot password '123456' -S /mysqldata/3308/mysql.sock

Warning: Using a password on the command line interface can be insecure.

5.2.7、分别使用mysql客户端登陆命令登陆端口号为3307、3308的mysql实例服务器

#登陆端口号为3307的mysql实例服务器:

[root@mysqldb1 3308]# mysql -uroot -p123456 -S /mysqldata/3307/mysql.sock

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.6.27-log Source distribution

Copyright (c) 2000, 2015, 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 |

| test               |

+--------------------+

4 rows in set (0.00 sec)

#在端口号为3307的mysql实例中登陆端口号为3308的mysql实例服务器:

mysql> system mysql -uroot -p123456 -S /mysqldata/3308/mysql.sock

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.27-log Source distribution

Copyright (c) 2000, 2015, 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 |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> quit

Bye

mysql> quit

Bye

5.2.8、分别使用mysql启动脚本测试端口号为3307、3308的mysql实例服务器

5.2.8.1、杀掉刚刚启动的mysql多例进程:

[root@mysqldb1 3308]# pkill mysqld

[root@mysqldb1 3308]# netstat -tulnp | grep 330

[1]-  Done                    /usr/local/mysql5.6.27/bin/mysqld_safe --defaults-file=/mysqldata/3307/my.cnf 2>&1 > /dev/null

[2]+  Done                    /usr/local/mysql5.6.27/bin/mysqld_safe --defaults-file=/mysqldata/3308/my.cnf 2>&1 > /dev/null

[root@mysqldb1 3308]# netstat -tulnp | grep 330

5.2.8.2、测试端口号为3307的服务器登陆脚本:

#启动端口号为3307的mysql

[root@mysqldb1 3308]# /mysqldata/3307/mysqld start

Starting MySQL...

[root@mysqldb1 3308]# netstat -tulnp | grep 3307

tcp        0      0 :::3307                     :::*                        LISTEN      50710/mysqld

#重启端口号为3307的mysql

[root@mysqldb1 3308]# /mysqldata/3307/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

[root@mysqldb1 3308]# netstat -tulnp | grep 3307

tcp        0      0 :::3307                     :::*                        LISTEN      51403/mysqld

#停止端口号为3307的mysql

[root@mysqldb1 3308]# /mysqldata/3307/mysqld stop

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

[root@mysqldb1 3308]# netstat -tulnp | grep 3307

5.2.8.3、测试端口号为3308的服务器登陆脚本:

#启动端口号为3308的mysql

[root@mysqldb1 3308]# /mysqldata/3308/mysqld start

Starting MySQL...

[root@mysqldb1 3308]# netstat -tulnp | grep 3308

tcp        0      0 :::3308                     :::*                        LISTEN      52104/mysqld

#重启端口号为3308的mysql

[root@mysqldb1 3308]# netstat -tulnp | grep 3308

tcp        0      0 :::3308                     :::*                        LISTEN      52104/mysqld

[root@mysqldb1 3308]# /mysqldata/3308/mysqld restart

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

[root@mysqldb1 3308]# netstat -tulnp | grep 3308

tcp        0      0 :::3308                     :::*                        LISTEN      52797/mysqld

#停止端口号为3308的mysql

[root@mysqldb1 3308]# /mysqldata/3308/mysqld stop

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

[root@mysqldb1 3308]# netstat -tulnp | grep 3308

5.2.9、分别启动端口号为3306、3307、3308的实例

[root@mysqldb1 ~]# for mport in 3306 3307 3308 ; do /mysqldata/$mport/mysqld start;done

Starting MySQL...

Starting MySQL...

Starting MySQL...

[root@mysqldb1 ~]# netstat -tulnp | grep 330

tcp        0      0 :::3307                     :::*                        LISTEN      12459/mysqld

tcp        0      0 :::3308                     :::*                        LISTEN      12441/mysqld

tcp        0      0 :::3306                     :::*                        LISTEN      12460/mysqld

5.2.10、分别重启端口号为3306、3307、3308的实例

[root@mysqldb1 ~]# for mport in 3306 3307 3308 ; do /mysqldata/$mport/mysqld restart; sleep 1 ;done

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Starting MySQL...

[root@mysqldb1 ~]# netstat -tulnp | grep 330

tcp        0      0 :::3307                     :::*                        LISTEN      12884/mysqld

tcp        0      0 :::3308                     :::*                        LISTEN      13070/mysqld

5.2.11、分别停止端口号为3306、3307、3308的实例

[root@mysqldb1 ~]# for mport in 3306 3307 3308 ; do /mysqldata/$mport/mysqld stop; sleep 1 ;done

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

Stoping MySQL...

Warning: Using a password on the command line interface can be insecure.

[root@mysqldb1 ~]# netstat -tulnp | grep 330

6、第二种通过官方自带的mysqld_multi来实现多实例实战

6.1、创建目录

[root@mysqldb1 ~]# /mysqlmulti/330{6,7,8}/

[root@mysqldb1 ~]# /mysqldata/

[root@mysqldb1 mysqlmulti]# mkdir conf

6.2、编辑配置文件

[root@mysqldb1 mysqlmulti]# vim conf/my.cnf

[mysqld_multi]

mysqld = /usr/local/mysql5.6.27/bin/mysqld_safe

mysqladmin = /usr/local/mysql5.6.27/bin/mysqladmin

user = root

password = 123456

[mysqld1]

socket = /mysqlmulti/3306/mysql.sock

port = 3306

pid-file = /mysqlmulti/3306/mysql3306.pid

datadir = /mysqlmulti/3306

user = mysql

skip-name-resolve

lower_case_table_names=1

innodb_file_per_table=1

back_log = 50

max_connections = 300

max_connect_errors = 1000

table_open_cache = 2048

max_allowed_packet = 16M

binlog_cache_size = 2M

max_heap_table_size = 64M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 64

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 2M

ft_min_word_len = 4

default-storage-engine = innodb

thread_stack = 192K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 64M

log-bin=mysql-bin

binlog_format=mixed

slow_query_log

long_query_time = 1

server-id = 1

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 2M

bulk_insert_buffer_size = 64M

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

innodb_additional_mem_pool_size = 16M

innodb_buffer_pool_size = 200M

innodb_data_file_path = ibdata1:10M:autoextend

innodb_file_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 512M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

innodb_lock_wait_timeout = 120

[mysqld2]

socket = /mysqlmulti/3307/mysql.sock

port = 3307

pid-file = /mysqlmulti/3307/mysql3307.pid

datadir = /mysqlmulti/3307

user = mysql

skip-name-resolve

lower_case_table_names=1

innodb_file_per_table=1

back_log = 50

max_connections = 300

max_connect_errors = 1000

table_open_cache = 2048

max_allowed_packet = 16M

binlog_cache_size = 2M

max_heap_table_size = 64M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 64

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 2M

ft_min_word_len = 4

default-storage-engine = innodb

thread_stack = 192K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 64M

log-bin=mysql-bin

binlog_format=mixed

slow_query_log

long_query_time = 1

server-id = 1

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 2M

bulk_insert_buffer_size = 64M

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

innodb_additional_mem_pool_size = 16M

innodb_buffer_pool_size = 200M

innodb_data_file_path = ibdata1:10M:autoextend

innodb_file_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 512M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

innodb_lock_wait_timeout = 120

[mysqld3]

socket = /mysqlmulti/3308/mysql.sock

port = 3308

pid-file = /mysqlmulti/3308/mysql3308.pid

datadir = /mysqlmulti/3308

user = mysql

skip-name-resolve

lower_case_table_names=1

innodb_file_per_table=1

back_log = 50

max_connections = 300

max_connect_errors = 1000

table_open_cache = 2048

max_allowed_packet = 16M

binlog_cache_size = 2M

max_heap_table_size = 64M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 64

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 2M

ft_min_word_len = 4

default-storage-engine = innodb

thread_stack = 192K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 64M

log-bin=mysql-bin

binlog_format=mixed

slow_query_log

long_query_time = 1

server-id = 1

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 2M

bulk_insert_buffer_size = 64M

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

innodb_additional_mem_pool_size = 16M

innodb_buffer_pool_size = 200M

innodb_data_file_path = ibdata1:10M:autoextend

innodb_file_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 512M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

innodb_lock_wait_timeout = 120

[mysqldump]

quick

max_allowed_packet = 256M

[mysql]

no-auto-rehash

prompt=\\u@\\d \\R:\\m>

[myisamchk]

key_buffer_size = 512M

sort_buffer_size = 512M

read_buffer = 8M

write_buffer = 8M

[mysqlhotcopy]

interactive-timeout

[mysqld_safe]

open-files-limit = 8192

6.3、初始化端口为3306、3307、3308的mysql数据库

[root@mysqldb1 mysqlmulti]# /usr/local/mysql5.6.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.27 --datadir=/mysqlmulti/3306

[root@mysqldb1 mysqlmulti]# /usr/local/mysql5.6.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.27 --datadir=/mysqlmulti/3307

[root@mysqldb1 mysqlmulti]# /usr/local/mysql5.6.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.27 --datadir=/mysqlmulti/3308

6.4、启动测试启动多实例数据库

[root@mysqldb1 mysqlmulti]# /usr/local/mysql5.6.27/bin/mysqld_multi --defaults-file=/mysqlmulti/conf/my.cnf --user=mysql start 1-3

[root@mysqldb1 mysqlmulti]# netstat -tulnp | grep 330

tcp        0      0 :::3307                     :::*                        LISTEN      47763/mysqld

tcp        0      0 :::3308                     :::*                        LISTEN      47699/mysqld

tcp        0      0 :::3306                     :::*                        LISTEN      47764/mysqld

6.5、停止mysql多实例数据库

[root@mysqldb1 mysqlmulti]# pkill mysql

[root@mysqldb1 mysqlmulti]# netstat -tulnp | grep 330

6.6、编写启动、停止、重启的控制脚本

[root@mysqldb1 mysqlmulti]# vim mysqld_multi

#!/bin/bash

basedir=/usr/local/mysql5.6.27

bindir=/usr/local/mysql5.6.27/bin

cfgfile=/mysqlmulti/conf/my.cnf

if test -x $bindir/mysqld_multi

then

my_multi="$bindir/mysqld_multi";

else

echo "Can't execute $bindir/mysqld_multi from dir $basedir";

exit;

fi

echo $my_multi

function startmulti(){

echo "Starting multi mysqld ......"

"$my_multi"  --defaults-file=$cfgfile  start $2

sleep 5

echo "Started multi mysqld ......"

}

function stopmulti(){

echo "Stopping multi mysqld ......"

ps -ef | /bin/grep /bin/mysqld | /bin/grep -v grep | /bin/awk '{print $2}' | /usr/bin/xargs kill -s 9

echo "Stopped multi mysqld ......"

}

function restartmulti(){

stopmulti

startmulti $2

}

case "$1" in

'start' )

startmulti $2

;;

'stop' )

stopmulti

;;

'restart' )

restartmulti $2

;;

*)

echo "Usage: $0 {start|stop|restart}" >&2

;;

esac

6.7、给启动脚本授可执行权限

[root@mysqldb1 mysqlmulti]# chmod +x mysqld_multi

[root@mysqldb1 mysqlmulti]# ll ./

total 20

drwxr-xr-x. 5 mysql mysql 4096 Oct 19 11:42 3306

drwxr-xr-x. 5 mysql mysql 4096 Oct 19 11:42 3307

drwxr-xr-x. 5 mysql mysql 4096 Oct 19 11:42 3308

drwxr-xr-x. 2 root  root  4096 Oct 19 09:34 conf

-rwxr-xr-x. 1 root  root   888 Oct 19 11:43 mysqld_multi

6.8、测试脚本是否正常

6.8.1、启动mysql多个实例

[root@mysqldb1 mysqlmulti]# ./mysqld_multi start 1-3

/usr/local/mysql5.6.27/bin/mysqld_multi

Starting multi mysqld ......

Started multi mysqld ......

[root@mysqldb1 mysqlmulti]# netstat -tlnpu | grep 330

tcp        0      0 :::3307                     :::*                        LISTEN      5127/mysqld

tcp        0      0 :::3308                     :::*                        LISTEN      5126/mysqld

tcp        0      0 :::3306                     :::*                        LISTEN      5102/mysqld

6.8.2、重启mysql多个实例

[root@mysqldb1 mysqlmulti]# ./mysqld_multi restart 1-3

/usr/local/mysql5.6.27/bin/mysqld_multi

Stopping multi mysqld ......

Stopped multi mysqld ......

Starting multi mysqld ......

Started multi mysqld ......

[root@mysqldb1 mysqlmulti]# netstat -tlnpu | grep 330

tcp        0      0 :::3307                     :::*                        LISTEN      7993/mysqld

tcp        0      0 :::3308                     :::*                        LISTEN      7999/mysqld

tcp        0      0 :::3306                     :::*                        LISTEN      7959/mysqld

6.8.3、关闭mysql实例

[root@mysqldb1 mysqlmulti]# ./mysqld_multi stop

/usr/local/mysql5.6.27/bin/mysqld_multi

Stopping multi mysqld ......

Stopped multi mysqld ......

[root@mysqldb1 mysqlmulti]# netstat -tlnpu | grep 330

6.8.4、单配置文件mysql用户密码密码:

1、启动mysql多实例

[root@mysqldb1 ~]# /mysqlmulti/mysqld_multi start 1-3

2、修改每个实例的管理员密码

[root@mysqldb1 ~]# for mport in  3306 3307 3308 ; do /usr/local/mysql5.6.27/bin/mysqladmin -uroot password '123456' -S /mysqlmulti/$mport/mysql.sock ; done

Warning: Using a password on the command line interface can be insecure.

Warning: Using a password on the command line interface can be insecure.

Warning: Using a password on the command line interface can be insecure.

3、使用命令登陆mysql各个实例进程

#使用命令登陆端口号为3306的mysql实例

[root@mysqldb1 ~]# mysql -uroot -p123456 -S /mysqlmulti/3306/mysql.sock

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.6.27-log Source distribution

Copyright (c) 2000, 2015, 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.

#查看端口号为3306的mysql实例的状态信息。

mysql> status

--------------

mysql  Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using  EditLine wrapper

Connection id: 5

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter: ;

Server version: 5.6.27-log Source distribution

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db     characterset: utf8

Client characterset: utf8

Conn.  characterset: utf8

UNIX socket: /mysqlmulti/3306/mysql.sock

Uptime: 13 min 27 sec

Threads: 1  Questions: 47  Slow queries: 0  Opens: 87  Flush tables: 1  Open tables: 80  Queries per second avg: 0.058

--------------

#在端口号为3306的mysql实例中登陆端口号为3307的mysql实例服务器,其中system是在不离开mysql服务器的同时能够执行linux外部命令的函数。

mysql> system mysql -uroot -p123456 -S /mysqlmulti/3307/mysql.sock

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.27-log Source distribution

Copyright (c) 2000, 2015, 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.

#端口号为3307的mysql实例的状态信息。

mysql> status

--------------

mysql  Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using  EditLine wrapper

Connection id: 3

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter: ;

Server version: 5.6.27-log Source distribution

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db     characterset: utf8

Client characterset: utf8

Conn.  characterset: utf8

UNIX socket: /mysqlmulti/3307/mysql.sock

Uptime: 14 min 25 sec

Threads: 1  Questions: 16  Slow queries: 0  Opens: 70  Flush tables: 1  Open tables: 63  Queries per second avg: 0.018

--------------

#登陆端口号为3308的mysql实例

mysql> system mysql -uroot -p123456 -S /mysqlmulti/3308/mysql.sock

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.27-log Source distribution

Copyright (c) 2000, 2015, 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.

#端口号为3307的mysql实例的状态信息。

mysql> status

--------------

mysql  Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using  EditLine wrapper

Connection id: 2

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter: ;

Server version: 5.6.27-log Source distribution

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db     characterset: utf8

Client characterset: utf8

Conn.  characterset: utf8

UNIX socket: /mysqlmulti/3308/mysql.sock

Uptime: 15 min 5 sec

Threads: 1  Questions: 10  Slow queries: 0  Opens: 70  Flush tables: 1  Open tables: 63  Queries per second avg: 0.011

--------------

#逐级退出mysql客户端实例

mysql> quit

Bye

mysql> quit

Bye

mysql> quit

Bye

mysqladmin 优雅关闭mysql

本文出自 “放牛娃” 博客,请务必保留此出处http://fangniuwa.blog.51cto.com/10209030/1757998

(转)mysql5.6.7多实例安装、配置的详细讲解分析及shell启动脚本的编写的更多相关文章

  1. mysql5.6.40单实例安装二进制快捷安装

    mysql5.6.40单实例安装二进制快捷安装 近期因不同环境需要不同版本的mysql实例,故为了方便操作,特此记录下来,方便自己查找. # 1.1.Centos最小化安装推荐常用依赖包 yum cl ...

  2. MySql-5.7.17-20解压缩版安装配置

    MySql-5.7.XXX解压缩版安装配置   1.mysql-5.7.20是解压版免安装的,版本下载地址:http://dev.mysql.com/downloads/mysql/ 如下图 2.解压 ...

  3. Linux下mysql 多实例安装配置

    首先我们要清楚什么是多实例?所谓多实例就是用多个配置文件来启动多个不同端口的进程,以不同的端口的形式为外提供服务.明白了多实例 我们下面的操作和配置就一目了然了首先我们要安装一套基础的应用程序,也就是 ...

  4. docker安装配置gitlab详细过程

    docker安装配置gitlab详细过程   获取镜像 1.方法一 1 docker pull beginor/gitlab-ce:11.0.1-ce.0 2.方法二如果服务器网路不好或者pull不下 ...

  5. 在linux下安装配置rabbitMQ详细教程

    在linux下安装配置rabbitMQ详细教程 2017年12月20日 17:34:47 阅读数:7539 安装Erlang 由于RabbitMQ依赖Erlang, 所以需要先安装Erlang. Er ...

  6. tcpdump安装配置及抓包分析

    http://blog.csdn.net/e421083458/article/details/23963189 cpdump安装配置及抓包分析 预装软件:[plain] view plain cop ...

  7. JDK下载安装配置教程(详细)

    JDK下载安装配置教程(详细) 版权声明:本文为原创文章,转载请附上原文出处链接和本声明.https://www.cnblogs.com/mxxbc/p/11844885.html 因为最近需要在Wi ...

  8. mysql-5.1.73多实例安装启动

    一.源码包下载:http://download.softagency.net/MySQL/Downloads/MySQL-5.1/ 二.编译安装 groupadd mysql useradd -r - ...

  9. mysql5.7单机多实例安装

    基于之前的mysql5.7单实例安装 修改/etc/my.cnf文件如下(这里配置4个实例,可自行修改数目) # # 多实例配置文件,可以mysqld_multi --example 查看例子 # [ ...

随机推荐

  1. Windows下启动redis错误1067:进程意外中止

    已解决: 在redis-64.3.0.503文件夹下新建一个空文件夹,命名为logs,如下图所示: 最后成功了 开启服务:redis-server --service-start

  2. DataGridView增加全选列

    最近的一个winform的项目中,碰到datagridview控件的第一列添加全选的功能,通常这个功能,有两种实现方式:1. 为控件添加DataGridViewCheckBoxColumn来实现,但是 ...

  3. day02.2-常用Linux命令整理

    Linux命令语法格式:   命令    [选项]    [参数] 1). 命令:告诉Linux操作系统执行什么: 2). 选项:说明命令的运行方式.选项部分是以字符‘-’开始的: 3). 参数:说明 ...

  4. java基础之流程控制语句

    一.     分支 1.      三元运算符 ?: 注意:三元运算符虽然简洁但是语法乱,而且必须要有接受者或者直接打印 1.     if else语句 另一种不带括号的写法: if(条件) 语句1 ...

  5. [BZOJ1799][Ahoi2009]self 同类分布(数位dp)

    题目描述 给出两个数 a,ba,b ,求出 [a,b][a,b] 中各位数字之和能整除原数的数的个数. 输入输出格式 输入格式: 一行,两个整数 aa 和 bb 输出格式: 一个整数,表示答案 输入输 ...

  6. iOS10 新特性-新功能,以及ReplayKit库

    iOS的10.0 本文总结了iOS的10,运行于目前推出iOS设备推出的主要开发者相关的功能. iOS版10引入了新的方法来增加您的应用程序通过帮助系统参与在适当的时候建议你的应用程序给用户.如果你在 ...

  7. luogu4240 毒瘤之神的考验(毒瘤乌斯反演)

    link 题意:求出\(\sum_{i=1}^n\sum_{j=1}^m\varphi(ij)\),对998244353取模 多组数据,\(T\le 10^4,n,m\le 10^5\). 前置知识: ...

  8. kuangbin专题十六 KMP&&扩展KMP HDU1686 Oulipo

    The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...

  9. 微信小程序生成带参二维码

    需求:生成小程序中的海报,需要小程序二维码可以使用户保存到本地在朋友圈分享 生成二维码工具类代码如下: package com.aone.foottalk.action.wx.util; import ...

  10. DRAM与SRAM

    传送门:https://www.cnblogs.com/nano94/p/4014082.html 关于内存的补充知识传送门:https://blog.csdn.net/Hello_Sue/artic ...