日期:2014-05-16  浏览次数:20908 次

mysql 多实例 安装
【1】源码安装mysql数据库
useradd mysql							
tar xzvf mysql-.1.55.tar.gz 					
cd mysql5.1.55					
./configure --prefix=/usr/local/mysql --with-extra-charsets=all  --exec-prefix=/usr/local/mysql --with-plugins=all		
make && make install
cd /usr/local/mysql/
chown -R mysql:mysql
cd /usr/local/src/mysql-5.1.55/support-files
cp my-medium.cnf /etc/my.cnf

【2】mysql多实例配置
mysql_install_db --basedir=/usr/local/mysql  --datadir=/var/lib/mysql-3308 --user=mysql
mysql_install_db --basedir=/usr/local/mysql  --datadir=/var/lib/mysql-3307 --user=mysql

[mysqld_multi]
mysqld     = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user     = root   //这个用户和密码是用来关闭mysql服务的
password = wxseio
 
[mysqld3307]
#其中  port ,socket,
#      pid-file,datadir
#这四个参数必须不同,其余可以根据自己选择设置。
datadir = /var/lib/mysql-3307
socket = /var/lib/mysql-3307/mysql.sock
pid-file = /var/lib/mysql-3307/mysqld.pid
user = root
port = 3307
server-id = 100

[mysqld3308]
datadir = /var/lib/mysql-3308
socket = /var/lib/mysql-3308/mysql.sock
pid-file = /var/lib/mysql-3308/mysqld.pid
user = root
port = 3308
server-id = 200

 mysqld_multi start  3007,3008
    mysqld_multi stop 3307,3308

netstate -lanp|grep mysql


注意:在本地登录本机的时候 -h  写的是localhost 或 127.0.0.1,会自动通过sock通信方式去连接本机上的MySQL server。