一、編譯安裝第一個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數據庫,則執(zhí)行以下兩步。如果你只是希望讓PHP支持MySQL擴展庫,能夠連接其他服務器上的MySQL數據庫,那么,以下兩步
無需執(zhí)行。
①、以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
注:如出現(xiàn) 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數據庫 本文出自:億恩科技【mszdt.com】
服務器租用/服務器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質保障!--億恩科技[ENKJ.COM]
|