一台centos装两个mysql

 参考:http://www.phpchina.com/archives/view-33724-1.html

 1072  cp support-files/my-medium.cnf /etc/my2.cnf
 1096  ./scripts/mysql_install_db --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/mycentos/  --user=mysql &      //安装的时候指定basedir与datadir
 1097  ./bin/mysqld_safe --defaults-file=/etc/my2.cnf  --user=mysql &       //启动的时候指定配置文件
 1121  mysql -uroot -p -S /tmp/mysql2.sock 

通过如下方式启动或者终止进程

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf

#/usr/local/mysql/bin/mysqladmin -uroot -p -S  /tmp/mysql.sock shutdown ----------- (------------通过指定配置文件或者是启动文件的的路径来确定启动或者终止相对应端口进程)
  1 <?php
  2 header("content-type:text/html;charset=utf-8");
  3 $cn=mysql_connect("localhost:3305:/tmp/mysql1.sock","root","123456");
  4 echo "连接成功3305";
  5 echo "<br/>";
  6 $cn=mysql_connect("localhost:3306:/tmp/mysql2.sock","root","");
  7 echo "连接成功3306";
  8 ?>
<?php
 $cn=mysql_connect("192.168.99.232:3305","yansiyu","123");
 //cms mysql -h192.168.99.232 -uyansiyu -p123 -P3305
 echo "success";
?>

参考:

1、http://blog.chinaunix.net/uid-25075782-id-2220164.html
2、
http://blog.sina.com.cn/s/blog_4b97332d0100va03.html
主从:
http://www.cnblogs.com/zgx/archive/2011/09/13/2174823.html

    A+
发布日期:2021年07月15日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: