Linux下mysql源碼安裝筆記
1.假設(shè)已經(jīng)有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz兩個源文件
(1)先安裝cmake(mysql5.5以后是通過cmake來編譯的)
[root@ rhel5 local]#tar -zxv -f cmake-2.8.4.tar.gz [root@ rhel5 local]#cd cmake-2.8.4 [root@ rhel5 cmake-2.8.4]#./configure [root@ rhel5 cmake-2.8.4]#make [root@ rhel5 cmake-2.8.4]#make install
(2)創(chuàng)建mysql的安裝目錄及數(shù)據(jù)庫存放目錄
[root@ rhel5~]#mkdir -p /usr/local/mysql //安裝mysql [root@ rhel5~]#mkdir -p /usr/local/mysql/data //存放數(shù)據(jù)庫
(3)創(chuàng)建mysql用戶及用戶組
[root@ rhel5~]groupadd mysql [root@ rhel5~]useradd -r -g mysql mysql
(4)安裝mysql
[root@ rhel5 local]#tar -zxv -f mysql-5.5.10.tar.gz [root@ rhel5 local]#cd mysql-5.5.10 [root@ rhel5 mysql-5.5.10]#cmake . -DCMAKE_INSTALL_PREFIX=/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@ rhel5 mysql-5.5.10]#make [root@ rhel5 mysql-5.5.10]#make install
參數(shù)說明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安裝目錄
-DINSTALL_DATADIR=/usr/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ù)
注意事項:
重新編譯時,需要清除舊的對象文件和緩存信息。
# make clean # rm -f CMakeCache.txt # rm -rf /etc/my.cnf
2.配置
(1)設(shè)置目錄權(quán)限
[root@ rhel5~]# cd /usr/local/mysql [root@ rhel5 mysql]# chown -R root:mysql . //把當(dāng)前目錄中所有文件的所有者所有者設(shè)為root,所屬組為mysql [root@ rhel5 mysql]# chown -R mysql:mysql data
(2)
[root@ rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //將mysql的啟動服務(wù)添加到系統(tǒng)服務(wù)中
(3)創(chuàng)建系統(tǒng)數(shù)據(jù)庫的表
[root@ rhel5 mysql]# cd /usr/local/mysql [root@ rhel5 mysql]# scripts/mysql_install_db --user=mysql
(4)設(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@ rhel5 mysql]# ./bin/mysqld_safe --user=mysql & //啟動MySQL,但不能停止
啟動日志寫在此文件下:/usr/local/mysql/data/localhost.err
關(guān)閉MySQL服務(wù)
[root@ rhel5 mysql]# mysqladmin -u root -p shutdown //這里MySQL的root用戶還沒有配置密碼,所以為空值。需要輸入密碼時,直接點(diǎn)回車鍵即可。
(6)另一種簡單的啟動mysql的方法(mysql已經(jīng)被添加到系統(tǒng)服務(wù)中)
[root@ rhel5~]# service mysql.server start [root@ rhel5~]# service mysql.server stop [root@ rhel5~]# service mysql.server restart
如果上述命令出現(xiàn):mysql.server 未識別的服務(wù)
則可能mysql還沒添加到系統(tǒng)服務(wù)中,下面用另一種方法添加:
[root@ rhel5 mysql]# cp support-files/mysql.server /etc/init.d/mysql //將mysql的啟動服務(wù)添加到系統(tǒng)服務(wù)中
注意:主要是將mysql.server拷貝到/etc/init.d中,命名為mysql。在有的系統(tǒng)中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系統(tǒng)中,mysql.server在/usr/local/mysql/support-files/mysql.server中。
然后再用#service mysql start 來啟動mysql即可。
(7)修改MySQL的root用戶的密碼以及打開遠(yuǎn)程連接
[root@ rhel5~]# mysql -u root mysql mysql>use mysql; mysql>desc user; mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //為root添加遠(yuǎn)程連接的能力。 mysql>update user set Password = password('xxxxxx') where User='root'; mysql>select Host,User,Password from user where User='root'; mysql>flush privileges; mysql>exit
重新登錄:mysql -u root -p
若還不能進(jìn)行遠(yuǎn)程連接,則關(guān)閉防火墻
[root@ rhel5~]# /etc/rc.d/init.d/iptables stop
注:如果不能遠(yuǎn)程連接,出現(xiàn)錯誤mysql error number 1130,則加入下面語句試試:
精彩專題分享:mysql不同版本安裝教程 mysql5.7各版本安裝教程
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Linux下rpm、yum和源碼三種安裝方式詳細(xì)介紹
- Linux下安裝mysql的方式(yum和源碼編譯兩種方式)
- linux下安裝mysql數(shù)據(jù)庫5.6源碼安裝,修改登錄用戶密碼
- linux下源碼安裝mysql5.6.20教程
- Linux CentOS 7源碼編譯安裝PostgreSQL9.5
- Linux CentOS6.6系統(tǒng)中安裝mysql源碼包的方法
- Linux下源碼編譯安裝配置SVN服務(wù)器的步驟分享
- SUSE Linux下源碼編譯方式安裝MySQL 5.6過程分享
- Linux+php+apache+oracle環(huán)境搭建之CentOS下源碼編譯安裝PHP
- 分析Linux內(nèi)核調(diào)度器源碼之初始化
相關(guān)文章
MySQL存儲表情時報錯:java.sql.SQLException: Incorrect string value:‘
這篇文章主要給大家介紹了關(guān)于MySQL存儲表情時報錯:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\xA9\x0D\x0A...'的解決方法,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來一起看看吧。2018-04-04mysql學(xué)習(xí)筆記之?dāng)?shù)據(jù)引擎
插件式存儲引擎是MySQL數(shù)據(jù)庫最重要的特征之一,用戶可以根據(jù)應(yīng)用的需要尋找如何存儲和索引數(shù)據(jù)、是否使用事務(wù)等。MySQL默認(rèn)支持多種存儲引擎,以適用于不同領(lǐng)域的數(shù)據(jù)庫應(yīng)用需求,用戶可以通過選擇選擇不同的存儲引擎提供應(yīng)用的效率,提供靈活的存儲2017-02-02windows無法啟動MySQL服務(wù)報錯1067的解決方法
這篇文章主要為大家詳細(xì)介紹了windows無法啟動MySQL服務(wù)報錯1067的3種解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-01-01MySQL中CONCAT和GROUP_CONCAT方法的區(qū)別詳解
本文主要介紹了MySQL中CONCAT和GROUP_CONCAT方法的區(qū)別詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01mysql指定某行或者某列的排序?qū)崿F(xiàn)方法
這篇文章主要介紹了mysql指定某行或者某列的排序,需要的朋友可以參考下2017-05-05