linux源码安装多个mysql,Linux下源码编译安装Mysql5.1及支持多个Mysql实例

Linux下源码编译安装Mysql5.1及支持多个Mysql实例

一、安装单实例Mysql5.1服务器

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql --with-charset=utf8 --without-debug --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --disable-shared --with-mysqld-user=mysql --with-extra-charsets=gb2312,big5,gbk

shell> make

shell> make install

shell> cp support-files/my-medium.cnf /etc/my.cnf

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig --level 2345 mysqld on

PATH=/usr/local/mysql/bin:$PATH

echo "PATH=/usr/local/mysql/bin:/$PATH" >> /etc/profile

shell> cd /usr/local/mysql

shell> bin/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

二、多实例安装Mysql5.1服务器

一、安装监听端口3306的Mysql服务器

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql3306 --with-unix-socket-path=/usr/local/mysql3306/var/mysql.sock --sysconfdir=/usr/local/mysql3306/etc --with-charset=utf8 --without-debug --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --disable-shared --with-mysqld-user=mysql --with-extra-charsets=gb2312,big5,gbk

shell> make

shell> make install

shell> mkdir /usr/local/mysql3306/etc

shell> cp support-files/my-medium.cnf /usr/local/mysql3306/etc/my.cnf

cp support-files/mysql.server /etc/init.d/mysqld3306

chmod 755 /etc/init.d/mysqld3306

chkconfig --add mysqld3306

chkconfig --level 2345 mysqld3306 on

PATH=/usr/local/mysql3306/bin:$PATH

echo "PATH=/usr/local/mysql3306/bin:/$PATH" >> /etc/profile

shell> cd /usr/local/mysql3306

shell> bin/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

修改my.cnf设置监听端口为3306

二、安装监听端口3307的Mysql服务器

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql3307 --with-unix-socket-path=/usr/local/mysql3307/var/mysql.sock --sysconfdir=/usr/local/mysql3307/etc --with-charset=utf8 --without-debug --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --disable-shared --with-mysqld-user=mysql --with-extra-charsets=gb2312,big5,gbk

shell> make

shell> make install

shell> mkdir /usr/local/mysql3307/etc

shell> cp support-files/my-medium.cnf /usr/local/mysql3307/etc/my.cnf

cp support-files/mysql.server /etc/init.d/mysql3307

chmod 755 /etc/init.d/mysql3307

chkconfig --add mysql3307

chkconfig --level 2345 mysql3307 on

PATH=/usr/local/mysql3306/bin:$PATH

echo "PATH=/usr/local/mysql3306/bin:/$PATH" >> /etc/profile

shell> cd /usr/local/mysql3307

shell> bin/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

修改my.cnf设置监听端口为3307

三、编译参数解析编译参数解析--prefix=/usr/local/mysql3306 指定安装路径--with-unix-socket-path=/usr/local/mysql3306/var/mysql.sock 指定socket的套接字文件,多个实例时必须指定,否则多个实例会同时默认取/tmp/mysql.sock--sysconfdir=/usr/local/mysql3306/etc mysql实例启动后的配置文件所在,默认是安装路径下的[PREFIX/etc]此处指定的目的是强调需为每个实例配置my.cnf,同时需要保证 /etc/my.cnf不存在,因为启动脚本一般会先去读/etc/my.cnf--with-charset=utf8 默认字符集--with-extra-charsets=gb2312,big5,gbk 支持的其他字符集,减少不必要的开销,Mysql默认支持20多种字符集--without-debug 去掉调试模式,据说可以优化--enable-assembler 使用一些字符函数的汇编版本,据说可以优化性能--with-client-ldflags=-all-static 以纯静态方式编译客户端,如果服务器实例上不需要客户端,这项可以不要,不过建议还是留着,登录到数据库服务器上,直接mysql已经是默认习惯了。--with-mysqld-ldflags=-all-static 以纯静态方式编译服务端,据说对性能优化很有用--disable-shared 不提供动态链接库--with-mysqld-user=mysql 启动用户设置为mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值