centos編譯安裝mariadb的詳細(xì)過程
centos編譯安裝mariadb
一般我不太愿意用mysql,那個玩意,有的時候不太友好。
我還是比較喜歡mariadb。
1:安裝cmake環(huán)境
安裝MariaDB之前,首先要安裝cmake,另外為了保證不缺依賴,使用yum或者rpm安裝依賴:readline-devel,zlib-devel,openssl-devel,libaio-devel并且readline-devel依賴于ncurses-devel,如果使用yum的話會自動將所需依賴安裝好,具體命令如下:
yum -y install readline-devel yum -y install zlib-devel yum -y install openssl-devel yum -y install libaio-devel yum -y install ncurses-devel
(1):進入/usr/local/download/目錄
cd /usr/local/download
(2):解壓源碼包
wget https: //cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz
(3):解壓CMake源碼包
tar -zxvf cmake -3.12.0 -rc1.tar.gz
(4):進入cmark的源碼目錄
cd cmake -3.12.0 -rc1
(5):運行當(dāng)前目錄下的一個文件
./bootstrap
(6):編譯并安裝(時間稍長)
gmake&&gmake install
(7):查看版本號
cmake --version
2:安裝mariadb
這個安裝和php及nginx的安裝類似,只是mariadb的編譯是使用cmake
這里提前預(yù)定mysql的安裝目錄為/usr/local/mariadb并且數(shù)據(jù)表文件目錄為/usr/local/mariadb /mysqldata,
(1):下載
cd /usr/local/download wget https://downloads.mariadb.org/f/mariadb-10.5.6/source/mariadb-10.5.6.tar.gz
(2):創(chuàng)建用戶及用戶組
groupadd mysql useradd -s /sbin/nologin -r -g mysql mysql
(3):解壓、預(yù)編譯、編譯安裝
# 解壓 tar -zxvf mariadb-10.5.6.tar.gz # 進入目錄 cd mariadb-10.5.6 # 預(yù)編譯,將與 cmake -j . \ -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \ -DMYSQL_DATADIR=/usr/local/mariadb/mysqldata/ \ -DSYSCONFDIR=/usr/local/mariadb \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 \ -DWITHOUT_TOKUDB=1 \ -DMYSQL_UNIX_ADDR=/usr/local/mariadb/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci # 編譯安裝 make&&make install
(4):配置啟動文件及權(quán)限等
# 進入安裝目錄 cd /usr/local/mariadb/ # 創(chuàng)建啟動文件 cp support-files/mysql.server /etc/init.d/mysqld # 添加執(zhí)行權(quán)限 chmod +x /etc/init.d/mysqld # 創(chuàng)建存放數(shù)據(jù)表目錄 mkdir -p mkdir /usr/local/mariadb/mysqldata/ # 創(chuàng)建存放mysql.sock目錄 mkdir -p mkdir /usr/local/mariadb/tmp/ # 修改mariadb目錄權(quán)限 chown -R mysql:mysql /usr/local/mariadb/ # 創(chuàng)建mariadb配置文件 vim /usr/local/mariadb/my.cnf [mysqld] basedir=/usr/local/mariadb/ datadir=/usr/local/mariadb/mysqldata/ port=3306 pid-file=/usr/local/mariadb/mysqldata/mysql.pid socket=/usr/local/mariadb/tmp/mysql.sock [mysqld_safe] log-error=/usr/local/mariadb/mysqldata/mysql.log [client] port=3306 socket=/usr/local/mariadb/tmp/mysql.sock default-character-set=utf8 # 刪除默認(rèn)mariadb配置文件(默認(rèn)加載默認(rèn)的my.cnf文件,不刪除,啟動會報錯) rm -rf /etc/my.cnf
(5):數(shù)據(jù)初始化
/usr/local/mariadb/scripts/mysql_install_db --datadir=/usr/local/mariadb/mysqldata
初始化成功:
[root@iZuf60ynur81p6k0ysvtneZ mariadb]# /usr/local/mariadb/scripts/mysql_install_db --datadir=/usr/local/mariadb/mysqldata Installing MariaDB/MySQL system tables in '/usr/local/mariadb/mysqldata' ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system Two all-privilege accounts were created. One is root@localhost, it has no password, but you need to be system 'root' user to connect. Use, for example, sudo mysql The second is root@localhost, it has no password either, but you need to be the system 'root' user to connect. After connecting you can set the password, if you would need to be able to connect as any of these users with a password and without sudo See the MariaDB Knowledgebase at https://mariadb.com/kb or the MySQL manual for more instructions. You can start the MariaDB daemon with: cd '.' ; ./bin/mysqld_safe --datadir='/usr/local/mariadb/mysqldata' You can test the MariaDB daemon with mysql-test-run.pl cd './mysql-test' ; perl mysql-test-run.pl Please report any problems at https://mariadb.org/jira The latest information about MariaDB is available at https://mariadb.org/. You can find additional information about the MySQL part at: https://dev.mysql.com Consider joining MariaDB's strong and vibrant community: https://mariadb.org/get-involved/
(7):確保/usr/local/mariadb目錄下的所有文件權(quán)限都是mysql
chown -R mysql:mysql /usr/local/mariadb/
(8):啟動mysql
至此,mariadb安裝成功,現(xiàn)在,我們來啟動數(shù)據(jù)庫:
/etc/init.d/mysqld start
啟動成功:
[root@iZuf60ynur81p6k0ysvtneZ mariadb]# /etc/init.d/mysqld start
Starting MariaDB.201015 17:26:58 mysqld_safe Logging to '/usr/local/mariadb/mysqldata/mysql.log'.
201015 17:26:58 mysqld_safe Starting mariadbd daemon with databases from /usr/local/mariadb/mysqldata
[ OK ](9):簡化mariadb操作命令
默認(rèn)操作mariadb命令:
/usr/local/mariadb/bin/mysql
比較長,用著不太方便,簡化方式其實和php是一樣的:
vim /root/.bash_profile
添加內(nèi)容:
alias mysql=/usr/local/mariadb/bin/mariadb
修改完成,重載一下文件:
source /root/.bash_profile
或者創(chuàng)建軟連接
ln -s /usr/local/mariadb/bin/mariadb /usr/bin/mariadb
(10):鏈接mariadb
Mariadb默認(rèn)沒有密碼,所以直接使用
mysql -uroot -p 如下所示: [root@iZuf60ynur81p6k0ysvtneZ mariadb]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 6 Server version: 10.5.6-MariaDB Source distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
數(shù)據(jù)庫的其他配置,請移步《Centos7.6配置lnmp》
(11):重啟服務(wù)器,運行mariadb報錯:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mariadb/tmp/mysql.sock' (2)
原因是找不到本地套接字文件mysql.sock
默認(rèn)位置是在/tmp/mysql.sock,但是我這里在my.cnf中配置了其位置:
在/usr/local/mariadb/tmp/mysql.sock
查看當(dāng)前目錄下是否有該文件,沒有的話,重新啟動mariadb,會自動生成mysql.sock文件,不要自己手動創(chuàng)建。
使用如下命令:(該命令,是我在安裝時已配置好)
/etc/rc.d/init.d/mysqld restart
(12):設(shè)置開機啟動
確保rc.local 文件有執(zhí)行權(quán)限,否則,開機啟動不生效
vim /etc/rc.d/rc.local
添加如下內(nèi)容:
/etc/rc.d/init.d/mysqld restart
至此,centos編譯安裝mariadb完成。
我這里都是指定位置安裝,配置文件都在安裝目錄下,因此刪除的時候相對比較方便。
升級的情況,之后要升級的時候會在寫。
卸載軟件的話,直接刪除目錄就好。
到此這篇關(guān)于centos編譯安裝mariadb的文章就介紹到這了,更多相關(guān)centos編譯安裝mariadb內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
MariaDB中的thread pool詳細(xì)介紹和使用方法
這篇文章主要介紹了MariaDB中的thread pool詳細(xì)介紹和使用方法,thread pool對高并發(fā)的環(huán)境是很好的一個解決方法,需要的朋友可以參考下2014-07-07
Mysql/MariaDB啟動時處于進度條狀態(tài)導(dǎo)致啟動失敗的原因及解決辦法
本文給大家介紹Mysql/MariaDB啟動時一直處于進度條狀態(tài),進度條結(jié)束后提示error。究竟是什么原因呢?該怎么解決呢?跟著小編一起看看該如何解決此問題呢。2015-09-09
MongoDB快速入門筆記(八)之MongoDB的java驅(qū)動操作代碼講解
這篇文章主要介紹了MongoDB快速入門筆記(八)之MongoDB的java驅(qū)動操作代碼講解的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-06-06
Windows10系統(tǒng)下安裝MariaDB 的教程圖解
MariaDB由MySQL的創(chuàng)始人麥克爾·維德紐斯主導(dǎo)開發(fā),他早前曾以10億美元的價格,將自己創(chuàng)建的公司MySQL賣給了SUN,此后,隨著SUN被甲骨文收購,MySQL的所有權(quán)也落入Oracle的手中。這篇文章給大家介紹Windows10系統(tǒng)下安裝MariaDB 的教程圖解,感興趣的朋友一起看看吧2018-12-12
Window7安裝MariaDB數(shù)據(jù)庫及系統(tǒng)初始化操作分析
這篇文章主要介紹了Window7安裝MariaDB數(shù)據(jù)庫及系統(tǒng)初始化操作,簡明扼要的分析了Windows7平臺上安裝mariadb數(shù)據(jù)庫的步驟、配置方法及相關(guān)注意事項,需要的朋友可以參考下2018-05-05

