Centos 5.2下裝置多個mysql數據庫設置裝備擺設詳解。本站提示廣大學習愛好者:(Centos 5.2下裝置多個mysql數據庫設置裝備擺設詳解)文章只能為提供參考,不一定能成為您想要的結果。以下是Centos 5.2下裝置多個mysql數據庫設置裝備擺設詳解正文
1、編譯裝置第一個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數據庫
2、編譯裝置第二個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數據庫