如果迫于预算,可采用在一台服务器上安装多个mysql的方式,但生产库中并不推荐这么做

[root@HE1 scripts]#cat /etc/my.cnf
[client]
#port        =3306
#socket        =/tmp/mysql.sock
#default-character-set=utf8
 
[mysql]
#default-character-set=utf8
 
[mysqld3306]
port        =3306
basedir        =/usr/local/mysql
datadir        =/data/mysql_3306
socket    = /tmp/mysql_3306.sock
slow_query_log_file= /data/mysql_3306/slow.log
log-error =/data/mysql_3306/error.log
log-bin =/data/mysql_3306/mysql-bin
sync_binlog = 1
binlog_format=row
transaction_isolation= REPEATABLE-READ
innodb_buffer_pool_size= 100m
 
[mysqld3308]
port    = 3308
basedir =/usr/local/mysql
datadir =/data/mysql_3308
socket  = /tmp/mysql_3308.sock
slow_query_log = 1
slow_query_log_file= /data/mysql_3308/slow.log
log-error =/data/mysql_3308/error.log
long_query_time =0.05
log-bin =/data/mysql_3308/mysql-bin
sync_binlog = 1
binlog_cache_size =4M
default-storage-engine=InnoDB
binlog_format=row
transaction_isolation= REPEATABLE-READ
innodb_buffer_pool_size= 100m
 
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld_safe
mysqladmin=/usr/local/mysql/bin/mysqladmin
 
 
#gtid_mode=on
#log_slave_updates=1
#enforce_gtid_consistency=1
 
[mysqldump]
quick
max_allowed_packet =32M


[root@HE1 scripts]#./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3306--defaults-file=/etc/my.cnf --user=mysql
 
[root@HE1scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --defaults-file=/etc/my.cnf --user=mysql
 
[root@HE1bin]# ./mysqld_multi --defaults-file=/etc/my.cnf start 3306,3308
[root@HE1 bin]#./mysqld_multi report
Reporting MySQLservers
MySQL server fromgroup: mysqld3306 is running
MySQL server fromgroup: mysqld3308 is running

 

 

 


[root@HE1 bin]# mysql-uroot -p -P3306 -h 192.168.1.48
Enter password:
Welcome to the MySQLmonitor.  Commands end with ; or \g.
Your MySQLconnection id is 6
Server version:5.6.16-log MySQL Community Server (GPL)
 
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
 
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
 
mysql> showdatabases;
+--------------------+
| Database           |
+--------------------+
| information_schema|
| 3306db             |
| mysql              |
| performance_schema|
| test               |
+--------------------+
5 rows in set (0.00sec)

 

 

[root@HE1 bin]#mysql -uroot -p -S /data/mysql_3306/mysql_3306.sock
Enter password:
Welcome to the MySQLmonitor.  Commands end with ; or \g.
Your MySQLconnection id is 7
Server version:5.6.16-log MySQL Community Server (GPL)
 
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
 
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
 
mysql> showdatabases;
+--------------------+
| Database           |
+--------------------+
| information_schema|
| 3306db             |
| mysql              |
| performance_schema|
| test               |
+--------------------+
5 rows in set (0.00sec)

 

 

[root@HE1 bin]#mysql -uroot -p -P3308 -h 192.168.1.48
Enter password:
Welcome to the MySQLmonitor.  Commands end with ; or \g.
Your MySQLconnection id is 7
Server version:5.6.16-log MySQL Community Server (GPL)
 
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
 
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
 
mysql> showdatabases;
+--------------------+
| Database           |
+--------------------+
| information_schema|
| 3308db             |
| mysql              |
| performance_schema|
| test               |
+--------------------+
5 rows in set (0.00sec)
 
mysql> quit
Bye

 

 

 

[root@HE1 bin]#mysql -uroot -p -S /data/mysql_3308/mysql_3308.sock
Enter password:
Welcome to the MySQLmonitor.  Commands end with ; or \g.
Your MySQLconnection id is 9
Server version:5.6.16-log MySQL Community Server (GPL)
 
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
 
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
 
mysql> showdatabases;
+--------------------+
| Database           |
+--------------------+
| information_schema|
| 3308db             |
| mysql              |
| performance_schema|
| test               |
+--------------------+
5 rows in set (0.00sec)


本文出自 “岁伏” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1753992

posted on 2016-08-19 17:13  岁伏  阅读(130)  评论(0编辑  收藏  举报