一台伺服器裝多個mysql

來源:互聯網
上載者:User

安裝第一個

mysql

mysql1:

使用預設配置



root@localhost usr]# groupadd mysql

[root@localhost usr]# useradd -g mysql mysql

[root@localhost usr]# cd /usr/local

[root@localhost local]# tar -zxvf mysql-5.5.9.tar.gz


[root@localhost local]# cd mysql-5.5.9

[root@localhost mysql-5.5.9#

cmake -DCMAKE_BUILD_TYPE:STRING=Release-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql -DCMAKE_USE_RELATIVE_PATHS:BOOL=OFF -DENABLED_PROFILING:BOOL=ON-DENABLE_DEBUG_SYNC:BOOL=OFF -DMYSQL_DATADIR:PATH=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock-DSYSCONFDIR:PATH=/etc -DWITHOUT_SERVER:BOOL=OFF -DWITH_EMBEDDED_SERVER:BOOL=OFF-DWITH_EXTRA_CHARSETS:STRING=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON-DWITH_LIBEDIT:BOOL=ON -DWITH_READLINE:BOOL=OFF -DWITH_SSL:STRING=no-DWITH_UNIT_TESTS:BOOL=OFF -DWITH_ZLIB:STRING=bundled -DENABLED_LOCAL_INFILE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_EXAMPLE_STORAGE_ENGINE=1

[root@localhost mysql-5.5.9]# make

[root@localhost mysql-5.5.9]# make install

[root@localhost mysql-5.5.9]# cd scripts/

[root@localhost mysql-5.5.9]# ./mysql_install_db--basedir=/usr/local/mysql --user=mysql --datadir=/usr/local/mysql/data

[root@localhost mysql-5.5.9]# cp support-files/my-large.cnf /etc/my.cnf

[root@localhost]# chown mysql.mysql /usr/local/mysql -R

[root@localhost]# cd /usr/local/mysql

[root@localhost mysql]#./bin/mysqladmin -uroot password mysql

[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql1

[root@localhost mysql]# chkconfig --add mysql1

[root@localhost mysql]# chkconfig --level mysql1 345 on

[root@localhost mysql]# chkconfig --list mysql1




安裝第二個

mysql

mysql2:

[root@localhost local]#useradd mysql2

[root@localhost local]# tar -zxvf mysql-5.5.9.tar.gz

[root@localhost local]# cd mysql-5.5.9

[root@localhost mysql-5.5.9#

cmake -DCMAKE_BUILD_TYPE:STRING=Release-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql6033-DCMAKE_USE_RELATIVE_PATHS:BOOL=OFF -DENABLED_PROFILING:BOOL=ON-DENABLE_DEBUG_SYNC:BOOL=OFF -DMYSQL_DATADIR:PATH=/usr/local/mysql6033/data -DMYSQL_TCP_PORT=6033-DMYSQL_UNIX_ADDR=/usr/local/mysql6033/data/mysql6.sock-DSYSCONFDIR:PATH=/usr/local/msyql6033/my6.cnf-DWITHOUT_SERVER:BOOL=OFF -DWITH_EMBEDDED_SERVER:BOOL=OFF-DWITH_EXTRA_CHARSETS:STRING=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON-DWITH_LIBEDIT:BOOL=ON -DWITH_READLINE:BOOL=OFF -DWITH_SSL:STRING=no-DWITH_UNIT_TESTS:BOOL=OFF -DWITH_ZLIB:STRING=bundled -DENABLED_LOCAL_INFILE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_EXAMPLE_STORAGE_ENGINE=1

[root@localhost mysql-5.5.9]# cd scripts/

[root@localhost mysql-5.5.9]# ./mysql_install_db--basedir=/usr/local/mysql6033 --user=mysql6--datadir=/usr/local/mysql6033/data

[root@localhost mysql-5.5.9]# cp support-files/my-large.cnf /etc/my6.cnf

[root@localhost]# chown mysql.mysql /usr/local/mysql6033 -R

[root@localhost]# cd /usr/local/mysql6033

[root@localhost mysql6033]#cp support-files/mysql.server /etc/rc.d/init.d/mysql2

[root@localhost mysql6033]#vi /etc/rc.d/init.d/mysql2


 $bindir/mysqld_safe --defaults-file=/etc/my6.cnf --datadir="$datadir" --user=mysql2--pid-file="$mysqld_pid_file_path" $other_args >/dev/null2>&1 &    

此處的紅字一定要放在最前面,即$bindir/mysqld_safe後面,否則報錯。)

[root@localhost mysql6033]/etc/rc.d/init.d/mysql2 start

[root@localhost mysql6033]#./bin/mysqladmin -u root password mysql - /usr/local/mysql6033/data/mysql6.sock


[root@localhost mysql]# chkconfig --add mysql2

[root@localhost mysql]# chkconfig --level mysql2 345 on

[root@localhost mysql]# chkconfig --list mysql2


終端訪問:

mysql -uroot -p  -P6033--socket=/usr/local/mysql6033/data/mysql6.sock




相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.