步骤如下:
一、编译安装两个mysql,步骤如下
下载Mysql ,此处以Mysql-6.0.11-alpha.tar.gz 为例
安装第一个数据库(主数据库)
(红色部分为默认数据库文件路径,可改成其他如:data、var等)
tar zxvf mysql-6.0.11-alpha.tar.gz
cd mysql-6.0.11-alpha
./configure –prefix=/usr/local/mysql3306 –sysconfdir=/usr/local/mysql/etc –with-tcp-port=3306 –localstatedir=/usr/local/mysql3306/var–with-unix-socket-path=/tmp/mysql3306.sock –with-charset=utf8 –with-collation=utf8_general_ci –with-extra-charsets=gbk,gb2312,binary –enable-thread-safe-client –with-plugins=innobase –with-mysqld-user=mysql –with-charset=utf8 –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static
make && make install
安装第二个数据库(从数据库)
tar zxvf mysql-6.0.11-alpha.tar.gz
cd mysql-6.0.11-alpha
./configure –prefix=/usr/local/mysql3307 –sysconfdir=/usr/local/mysql3307/etc –with-tcp-port=3307 –localstatedir=/usr/local/mysql3307/var–with-unix-socket-path=/tmp/mysql3307.sock –with-charset=utf8 –with-collation=utf8_general_ci –with-extra-charsets=gbk,gb2312,binary –enable-thread-safe-client –with-plugins=innobase –with-mysqld-user=mysql –with-charset=utf8 –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static
make && make install
如需支持所有字符集 修改为:–with-extra-charsets=all 即可
二、分别初始化数据库脚本(在编译目录执行下)
scripts/mysql_install_db –basedir=/usr/local/mysql3306/ –user=mysql
scripts/mysql_install_db –basedir=/usr/local/mysql3307/ –user=mysql
注:可用–datadir=PATH参数指定数据库文件路径,默认为编译时– localstatedir
三、修改从库配置文件
拷贝配置文件:
cp /usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf
cp /usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf /usr/local/mysql3307/etc/my.cnf
四、修改各个数据库的my.cnf文件
主要内容如下:
添加InnoDB支持:
[client]
#password = your_password
port = 3307 –数据库端口号
socket = /tmp/mysqls.sock –sock文件路径
default-character-set=utf8 –客户端UTF8连接
[mysqld]
port = 3307 –数据库端口号
socket = /tmp/mysqls.sock –sock文件路径
default-storage-engine=INNODB
default-character-set=UTF8 –默认字符集
init_connect=’SET NAMES utf8′ –以UTF8连接
skip-name-resolve –取消DNS反向解析
lower_case_table_names=1 –不区分表名大小写
启动数据库(进入各自目录)
主:./scripts/mysqld_safe &
从:./scripts/mysqld_safe &
配置开启自动:
cp /usr/local/software/mysql-6.0.11-alpha/support-files/mysql.server /etc/init.d/mysql
cp /usr/local/software/mysql-6.0.11-alpha/support-files/mysql.server /etc/init.d/mysql3307
修改/etc/init.d/mysql3007中basedir与datadir为即可
basedir=/usr/local/mysql3307
datadir=/usr/local/mysql3307/var
停止数据库
主:./mysqladmin shutdown
从:./mysqladmin shutdown
2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有站币奖励和额外收入!
三优资源网 » Linux下安装启动多个Mysql
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 找不到素材资源介绍文章里的示例图片?
- 三优资源网