MySQL社区

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 7598|回复: 3
打印 上一主题 下一主题

在同一台机启动多个MySQL服务

[复制链接]
跳转到指定楼层
1#
发表于 2007-10-17 09:15:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
此功能给我带来的很大的方便,现在简要总结出来,以便给朋友们有所帮助。

在同一台机启动多个MySQL服务,多个服务可以是不同版本,同时运行。

以下给出一个简单的例子,只做个思路引导,在Linux平台中同时运行MySQL5.0和MySQL6.0两个服务,需要注意的是在安装时需要用MySQL的non RPM packages包的类型安装,方便安装到不同的目录中,可以从http://dev.mysql.com/downloads/mysql/5.0.html#linux得到下载包。


服务启动
  1. 1、启动MySQL5.0(默认的方式,正常启动)

  2. 2、登陆MySQL5.0
  3. [root@MyWebsite mysql]# mysql -S /opt/lampp/var/mysql/mysql.sock
  4. Welcome to the MySQL monitor. Commands end with ; or \g.
  5. Your MySQL connection id is 1
  6. Server version: 5.0.45 Source distribution

  7. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  8. mysql>

  9. 3、启动MySQL6.0
  10. [root@MyWebsite mysql]# bin/mysqld_safe --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --socket=/tmp/my.sock --port=3307&
  11. [1] 5237
  12. [root@MyWebsite mysql]# Starting mysqld daemon with databases from /usr/local/mysql/data

  13. 4、登陆MySQL6.0
  14. [root@MyWebsite mysql]# mysql -S /tmp/my.sock
  15. Welcome to the MySQL monitor. Commands end with ; or \g.
  16. Your MySQL connection id is 1
  17. Server version: 6.0.2-alpha MySQL Community Server (GPL)

  18. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  19. mysql>
复制代码
监控和查看MySQL运行情况
  1. 1、查看进程
  2. ps -ef|grep mysql
  3. netstat -nl

  4. 2、查看端口
  5. [root@MyWebsite mysql]# netstat -nl
  6. Active Internet connections (only servers)
  7. Proto Recv-Q Send-Q Local Address Foreign Address State
  8. tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
  9. tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN
  10. tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
  11. tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
  12. tcp 0 0 0.0.0.0:858 0.0.0.0:* LISTEN
  13. tcp 0 0 :::22 :::* LISTEN
  14. udp 0 0 0.0.0.0:68 0.0.0.0:*
  15. udp 0 0 0.0.0.0:852 0.0.0.0:*
  16. udp 0 0 0.0.0.0:855 0.0.0.0:*
  17. udp 0 0 0.0.0.0:111 0.0.0.0:*
  18. udp 0 0 0.0.0.0:631 0.0.0.0:*
  19. ......
复制代码
远程登陆这两个MySQL服务的方法
  1. 1、先在服务器上设置远程登陆的帐号及权限
  2. mysql> grant all on *.* to 'root'@'%' identified by 'xxxx';
  3. Query OK, 0 rows affected (0.02 sec)

  4. 2、远程登陆(需要任意MySQL客户端)
  5. C:\>mysql -uroot -proot -h192.168.0.5 -P 3306
  6. Welcome to the MySQL monitor. Commands end with ; or \g.
  7. Your MySQL connection id is 4 to server version: 5.0.45

  8. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  9. mysql>


  10. C:\>mysql -uroot -proot -192.168.0.5 -P 3307
  11. Welcome to the MySQL monitor. Commands end with ; or \g.
  12. Your MySQL connection id is 4 to server version: 6.0.2-alpha

  13. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  14. mysql>
复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享淘帖 顶 踩
2#
 楼主| 发表于 2007-11-12 12:08:17 | 只看该作者
如果服务器繁忙,可以用来部署负载均衡...
fire9 该用户已被删除
3#
发表于 2008-3-24 12:55:23 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
zhanghuiyun0978 该用户已被删除
4#
发表于 2008-11-25 16:07:53 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|申请友链|小黑屋|Archiver|手机版|MySQL社区 ( 京ICP备07012489号   
联系人:周生; 联系电话:13911732319

GMT+8, 2024-5-3 02:17 , Processed in 0.108196 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表