程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> Centos 5.2下安裝多個mysql數據庫配置詳解

Centos 5.2下安裝多個mysql數據庫配置詳解

編輯:關於MYSQL數據庫

一、編譯安裝第一個MySQL 5.1.33

cd /opt

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql -s /bin/nologin -d /usr/local/mysql

tar -zxvf mysql-5.1.33.tar.gz

cd mysql-5.1.33/

./configure --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase

make && make install

chmod +w /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

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

cd ../


附:以下為附加步驟,如果你想在這台服務器上運行MySQL數據庫,則執行以下兩步。如果你只是希望讓PHP支持MySQL擴展庫,能夠連接其他服務器上的MySQL數據庫,那麼,以下兩步無需執行。

①、以mysql用戶帳號的身份建立數據表:

/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

②、啟動MySQL(最後的&表示在後台運行)

/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &

echo "/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &" >> /etc/rc.local

ln -s /usr/local/mysql/bin/mysql /sbin/mysql 

ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin


mysqladmin -u root password 1234 --初始化root密碼

mysqladmin -u root -p password 456 --修改root已設置好的密碼

mysql -u root -p         --用新密碼連接數據庫



添加mysql帳戶 

grant all on *.* to 

'mysql3306'@'%' identified by 'mysql3306';     --添加用戶mysql3306用於遠程管理mysql數據庫

二、編譯安裝第二個mysql 5.1.33:


注:可以將第一個mysql的安裝文件全部復制過來,為了熟練安裝過程,這裡就再來重新安裝一遍

cd /opt

/usr/sbin/useradd -g mysql mysql3307 -s /bin/nologin -d /usr/local/mysql3307

tar -zxvf mysql-5.1.33.tar.gz

cd mysql-5.1.33/

./configure --prefix=/usr/local/mysql3307/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase

make;make install

chmod +w /usr/local/mysql3307

chown -R mysql3307:mysql /usr/local/mysql3307

chmod -R 777 /usr/local/mysql3307

cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql3307/my.cnf


修改配置文件:

port = 3307                   --修改端口

socket = /tmp/mysql3307.sock       --修改sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port = 3307

socket = /tmp/mysql3307.sock

①、以mysql用戶帳號的身份建立數據表:

/usr/local/mysql3307/bin/mysql_install_db --basedir=/usr/local/mysql3307 --datadir=/usr/local/mysql3307/data --user=mysql3307

②、啟動MySQL(最後的&表示在後台運行)

/bin/sh /usr/local/mysql3307/bin/mysqld_safe --defaults-file=/usr/local/mysql3307/my.cnf &

echo "/bin/sh /usr/local/mysql3307/bin/mysqld_safe --defaults-file=/usr/local/mysql3307/my.cnf &" >> /etc/rc.local



注:如出現 warning world-writable config file ' /usr/local/mysql3307/my.cnf' is ignored

解決辦法:  chmod 644 /usr/local/mysql3307/my.cnf

mysqladmin -P 3307 -S/tmp/mysql3307.sock -u root password 1q2w3e --初始化root密碼

mysqladmin -P 3307 -S/tmp/mysql3307.sock -u root -p password 1q2w3e --修改root已設置好的密碼

/usr/local/mysql3307/bin/mysql -uroot -p -S/tmp/mysql3307.sock


添加mysql帳戶 

grant all on *.* to 

'mysql3307'@'%' identified by 'mysql3307';     --添加用戶mysql3307用於遠程管理mysql數據庫

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved