Linux 安裝兩個MySQL伺服器的操作步驟

2021-08-09 21:05:56 字數 3971 閱讀 2578

mysql版本:mysql-5.6

安裝步驟:

第乙個mysql安裝路徑/usr/local/mysql 監聽3306埠

啟動檔案/etc/init.d/mysql

第二個mysql安裝路徑/data/mysql 監聽3307埠

啟動檔案/etc/init.d/mysql2

安裝第乙個

setup 1:

#wget

#tar -zxvf cmake-2.8.12.2.tar.gz

#cd cmake-2.8.12.2

#./bootstrap

#./configure

#make && make install

系統如果是centos,剛要安裝另乙個元件

#wget

#./configure

#make && make install

setup 2:

安裝mysql 5.5.37

#wget

tar -zxvf mysql-5.5.37.tar.gz

#cd mysql-5.5.37

#cmake -dcmake_install_prefix=/usr/local/mysql -dextra_charsets=all -denabled_local_infile=1 -dwith_readline=1 -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dwith_embedded_server=1 -dwith_ssl=system

#make && make install

慢長的等待過後終於完成了

#groupadd mysql

#useradd -g mysql mysql

#cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

#vim /etc/my.cnf #需要加入basedir,和datadir否則會出問題

[mysqld]

basedir =/usr/local/mysql

datadir =/usr/local/mysql/data

#/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &

#chown -r mysql /usr/local/mysql/data

#chgrp -r mysql /usr/local/mysql/.

#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

#chmod 755 /etc/init.d/mysql

#chkconfig --level 345 mysql on

#echo 「/usr/local/mysql/lib/mysql」 >> /etc/ld.so.conf

#echo 「/usr/local/lib」 >>/etc/ld.so.conf

#ldconfig

#/etc/init.d/mysql start

#/usr/local/mysql/bin/mysqladmin -u root password broadengate

empire cms,phome.net

#/etc/init.d/mysql restart

#/etc/init.d/mysql stop

ok終於完成~

安裝第2個

#tar -zxvf mysql-5.5.37.tar.gz

#cd mysql-5.5.37

#cmake -dcmake_install_prefix=/data/mysql -dmysql_datadir=/data/mysql/data -dextra_charsets=all -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dwith_innobase_storage_engine=1 -dwith_archive_storage_engine=1 -dwith_blackhole_storage_engine=1 -dwith_federated_storage_engine=1 -dwith_partition_storage_engine=1 -dwith_perfschema_storage_engine=1 -dmysql_unix_addr=/data/mysql/mysqld.sock -dmysql_tcp_port=3307 -dwith_debug=0 -denabled_local_infile=1 -dwith_readline=1 -dwith_ssl=system -dwith_zlib=system -dwith_embedded_server=1

#make && make install

#cp /data/mysql/support-files/my-medium.cnf /data/mysql/my.cnf

#vim /data/mysql/my.cnf #需要加入basedir,和datadir否則會出問題

[mysqld]

basedir =/data/mysql

datadir =/data/mysql/data

#/data/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data &

#chown -r mysql /data/mysql/data

#chgrp -r mysql /data/mysql/.

#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql2

#chmod 755 /etc/init.d/mysql2

好了,下面才是重點

#vi /etc/init.d/mysql2

1)找到以下檔案進行新增

basedir=/data/mysql

datadir=/data/mysql/data

conf=/data/mysql/my.cnf

2)修改以下引數

把$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1&替換為:

$bindir/mysqld_safe --defaults-file=/data/mysql/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &

3)把下面這句注釋掉(前面加個#):

parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`

4).儲存退出並新增服務:

chkconfig --add /etc/init.d/mysql2

分別啟動2個

# /etc/init.d/mysql start

# /etc/init.d/mysql2 start

所不同的是,我們在第二個mysql登陸時要加上sock可以進入,否則預設是第乙個資料庫

1

mysql -uroot -p --socket=/data/mysql/mysql.sock

linux安裝兩個tomcat

解壓apache tomcat 7.0.86.tar.gz,把解壓後的複製乙份 修改 etc profile檔案 vim etc profile 我新增的start first tomcat export catalina base catalina home tomcat home second ...

window下安裝兩個mysql服務

產生這個想法主要是因為win系統之前裝了mysql,服務名為mysql。又重新安裝xampp,導致mysql衝突,xampp中的mysql始終啟動不起來。解決方法如下 1 修改xampp中mysql的埠,開啟my.ini client port 3366 mysqld port 3366 2 建立m...

安裝兩個tomcat

編輯環境變數 vi etc profile 加入以下 tomcat路徑要配置自己實際的tomcat安裝目錄 first tomcat catalina base usr local tomcat catalina home usr local tomcat tomcat home usr local...