mysql5.1.73編譯安裝教程-改進後的
mysql 5.1.73官方下載地址
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz
md5:887f869bcc757957067b9198f707f32f
1 |
md5sum mysql-5.5.38. tar .gz #計算md5校驗和 |
2 |
tar -zxf mysql-5.1.73 #解壓到當前資料夾 |
隨便下載到什麼地方
然後執行下面 的
mkdir -p /db/mysql
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/var
mkdir -p /usr/local/mysql/data && mkdir -p /usr/local/mysql/run && mkdir -p /usr/local/mysql/log && mkdir -p /usr/local/mysql/var
useradd -s /sbin/nologin mysql
chown -R mysql.mysql /db/mysql/
chown -R mysql.mysql /usr/local/mysql/
yum install -y gcc yum install -y gcc-c++ yum -y install ncurses* yum install -y libtermcap*
./configure --enable-thread-safe-client --enable-assembler --with-server-suffix =" for >>>MySQL Database of Zebra by Yhc<<<" --without-debug --with-extra-charsets=complex --prefix=/usr/local/mysql
make -j 12 && make install 這裡的-j 12 沒看懂啥子意思
#新增PATH
echo "PATH=\"/usr/local/mysql/bin:\$PATH\"" >> /etc/profile && export PATH="/usr/local/mysql/bin:$PATH"
#strip可執行檔案
strip /usr/local/mysql/libexec/mysqld
#新增LIB PATH
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf && ldconfig
#將my.cnf檔案cp到/etc目錄下
/bin/cp -r /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf && chown mysql:mysql /etc/my.cnf
sed -i 's/skip-federated/#skip-federated/' /etc/my.cnf
cd /usr/local/mysql/bin
ln -s ./mysql ./test_mysql
ln -s ./mysqladmin ./adminmysql
ln -s ./mysql_install_db ./install_db_mysql
ln -s ./mysqld_safe ./safe_mysqld
#初始化Mysql表
cd /usr/local/mysql/bin
./install_db_mysql --user=mysql 或者 ./mysql_install_db --user=mysql --datadir=/db/mysql/
若是多例項的話要分別初始化,如果你只是預設的一個例項,下面的三個就不用執行了
./mysql_install_db --user=mysql --datadir=/db/mysql/data1 --defaults-file=/etc/my.cnf
./mysql_install_db --user=mysql --datadir=/db/mysql/data2 --defaults-file=/etc/my.cnf
./mysql_install_db --user=mysql --datadir=/db/mysql/data3 --defaults-file=/etc/my.cnf
啟動多例項
啟動全部例項:/usr/local/mysql/bin/mysqld_multi start
檢視全部例項狀態:/usr/local/mysql/bin/mysqld_multi report
我們僅僅啟動單個例項:/usr/local/mysql/bin/mysqld_multi start 3306
停止單個例項:/usr/local/mysql/bin/mysqld_multi stop 3306
檢視單個例項狀態:/usr/local/mysql/bin/mysqld_multi report 3306
# 單個例項啟動或關閉
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 1
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 2
# 雙例項同時啟動或關閉
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 1,2
# 檢視MySQL是否啟動,,這個不一定好用,先不管
# mysqld_multi --defaults-file=./my.cnf report 1,2
mysql -S /tmp/mysql11.sock 進入第一個庫 這個也先不管
mysql -S /tmp/mysql22.sock 進入第二個庫 這個也先不管
把下面的執行了
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chown -R root /usr/local/mysql && chown -R mysql /usr/local/mysql/var && chgrp -R mysql /usr/local/mysql
然後啟動mysql
service mysqld start
然後登陸命令列的mysql
mysql -u root -p 回車密碼為空
然後執行下面的SQL
use mysql;
update user set host = '%' where user = 'root' and host = 'localhost';
exit;
記得分號
然後
service mysqld stop
service mysqld start
然後這個時候你可以再地球上的其他地方遠端訪問你的mysql伺服器了.記住哦,密碼為空哦
如果喜歡我的教程請多多支援麻將幣哦