一台服务器启动多个mysql实例

1、安装mysql

   软件下载地址:http://www.percona.com/

安装依赖库:yum install cmake bison ncurses-devel gcc-c++

#rpm -ivh --nodeps --force Percona-Server-55-debuginfo-5.5.24-rel26.0.256.rhel6.x86_64.rpm                                   Percona-Server-server-55-5.5.24-rel26.0.256.rhel6.x86_64.rpm

                           Percona-Server-client-55-5.5.24-rel26.0.256.rhel6.x86_64.rpm                                     Percona-Server-shared-55-5.5.24-rel26.0.256.rhel6.x86_64.rpm

                        Percona-Server-devel-55-5.5.24-rel26.0.256.rhel6.x86_64.rpm    忽略报错


2、创建mysql目录    

   实例1:/home/mysql   启动3306端口    

   #mkdir -p /home/mysql/{data,logs}
   #chown mysql:mysql /home/mysql/ -R

     实例2:/usr/local/mysql启动3307端口

   #mkdir -p /usr/local/mysql/{data,logs,etc,var}
   #chown mysql:mysql /usr/local/mysql/ -R

3、修改实例2的配置文件
   #vi /user/local/mysql/etc/my.cnf
   [client]
   port            = 3307
   socket          = /usr/local/mysql/var/mysql.sock
   [mysqld]
   port            = 3307
   socket          = /var/lib/mysql/mysql-3307.sock
   datadir         = /usr/local/mysql/data
   log_error       = /usr/local/mysql/logs/db_error.log

4、安装mysql数据库系统表

#/usr/bin/mysql_install_db  --defaults-file=/etc/my.cnf  --basedir=/usr/  --datadir=/home/mysql/data  --user=mysql

  #/usr/bin/mysql_install_db  --defaults-file=/usr/local/mysql/etc/my.cnf  --basedir=/usr/  --datadir=/usr/local/mysql/data  --user=mysql
5、启动数据库
    /usr/bin/mysqld_safe  --defaults-file=/etc/my.cnf &
    /usr/bin/mysqld_safe  --defaults-file=/usr/local/mysql/etc/my.cnf &

原文地址 http://ja5on.blog.51cto.com/8521911/1353810

你可能感兴趣的:(mysql,单台多实例)