資源描述:
《Linux安裝mysql——源碼安裝》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、1.假設(shè)已經(jīng)有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz兩個源文件(1)先安裝cmake(mysql5.5以后是通過cmake來編譯的)[root@rhel5local]#tar-zxv-fcmake-2.8.4.tar.gz[root@rhel5local]#cdcmake-2.8.4[root@rhel5cmake-2.8.4]#./configure[root@rhel5cmake-2.8.4]#make[root@rhel5cmake-2.8.4]#makeinstall(2)創(chuàng)建mysql的安裝目錄及數(shù)據(jù)庫存放目錄[root@rhel5~]
2、#mkdir-p/usr/local/mysql//安裝mysql[root@rhel5~]#mkdir-p/usr/local/mysql/data//存放數(shù)據(jù)庫(3)創(chuàng)建mysql用戶及用戶組[root@rhel5~]groupaddmysql[root@rhel5~]useradd-r-gmysqlmysql(4)安裝mysql[root@rhel5local]#tar-zxv-fmysql-5.5.10.tar.gz[root@rhel5local]#cdmysql-5.5.10[root@rhel5mysql-5.5.10]#cmake.-DCMAKE_INSTALL_PRE
3、FIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DEXTRA_CHARSETS=all-DENABLED_LOCAL_INFILE=1[root@rhel5mysql-5.5.10]#make[root@rhel5mysql-5.5.10]#makeinstall參數(shù)說明:-DCMAKE_INSTALL_PREFIX=/usr/local/mysql//安裝目錄-DINSTALL_DATADIR=/usr/
4、local/mysql/data//數(shù)據(jù)庫存放目錄-DDEFAULT_CHARSET=utf8 //使用utf8字符-DDEFAULT_COLLATION=utf8_general_ci//校驗字符-DEXTRA_CHARSETS=all //安裝所有擴(kuò)展字符集-DENABLED_LOCAL_INFILE=1 //允許從本地導(dǎo)入數(shù)據(jù)注意事項:重新編譯時,需要清除舊的對象文件和緩存信息。#makeclean#rm-fCMakeCache.txt#rm-rf/etc/my.cnf2.配置(1)設(shè)置目錄權(quán)限[root@rhel5~]#cd/usr/local/mysql[roo
5、t@rhel5mysql]#chown-Rroot:mysql. //把當(dāng)前目錄中所有文件的所有者所有者設(shè)為root,所屬組為mysql[root@rhel5mysql]#chown-Rmysql:mysqldata(2)[root@rhel5mysql]#cpsupport-files/my-medium.cnf/etc/my.cnf //將mysql的啟動服務(wù)添加到系統(tǒng)服務(wù)中(3)創(chuàng)建系統(tǒng)數(shù)據(jù)庫的表[root@rhel5mysql]#cd/usr/local/mysql[root@rhel5mysql]#scripts/mysql_install_db--user=mysql(4)
6、設(shè)置環(huán)境變量[root@rhel5~]#vi/root/.bash_profile在PATH=$PATH:$HOME/bin添加參數(shù)為:PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib[root@rhel5~]#source/root/.bash_profile(5)手動啟動mysql[root@rhel5~]#cd/usr/local/mysql[root@rhel5mysql]#./bin/mysqld_safe--user=mysql& //啟動MySQL,但不能停止啟動日志寫在此文件下:/usr/loc
7、al/mysql/data/localhost.err關(guān)閉MySQL服務(wù)[root@rhel5mysql]#mysqladmin-uroot-pshutdown //這里MySQL的root用戶還沒有配置密碼,所以為空值。需要輸入密碼時,直接點回車鍵即可。(6)另一種簡單的啟動mysql的方法(mysql已經(jīng)被添加到系統(tǒng)服務(wù)中)[root@rhel5~]#servicemysql.serverstart[root@rhel5~]#servic