201501221246MariaDB 5.5 / 10.0 安裝 - CentOS - LAMP

 從 MariaDB 官網上的一句話「MariaDB is a drop-in replacement for MySQL.」,就可以知道他是要來幹掉 MySQL 的。不過對於系統開發或管理者,您不用太過於擔心努力那麼久的 MySQL 心血會白費,因為 MariaDB 的創始者跟  MySQL 創始者是同一人,他是不爽 Oracle 對 MySQL 的處理方式,進而重新開發新的「MariaDB」,目前的版本為 5.5 (對應 MySQL 的 5.5版)與新一代的 10.0.15 Stable。

MariaDB 官方說明:MariaDB strives to be the logical choice for database professionals looking for a robust, scalable, and reliable SQL server. To accomplish this, the MariaDB Foundation work closely and cooperatively with the larger community of users and developers in the true spirit of Free and open source software, and release software in a manner that balances predictability with reliability.

MariaDB Knowledge Base  https://mariadb.com/kb/en/ 
MariaDB 10新版大躍進 http://www.ithome.com.tw/news/86622 

-----------------------------------------------------------------------------------------------

要安裝 MariaDB 很簡單只需要執行「yum -y install MariaDB-server MariaDB-client」,但.....

預設 yum 套件是找不到的
$ yum info MariaDB-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.cs.nctu.edu.tw
* epel: mirror01.idc.hinet.net
* extras: centos.cs.nctu.edu.tw
* updates: centos.cs.nctu.edu.tw
Error: No matching Packages to list

可以使用增加「/etc/yum.repos.d/mariadb.repo」檔案,並設定如下的內容

sudo vi /etc/yum.repos.d/mariadb.repo    
// 底下 repos.d 有分 x64, x32 跟 5.5, 10.0  個別不同的套件庫來源,可以依您自己的系統把不需要的給註解#掉


# MariaDB 5.5 CentOS repository list - created 2014-01-10 13:53 UTC
# http://mariadb.org/mariadb/repositories/
# 64 bit ----------------------------------------
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#[mariadb]
#name = MariaDB
#baseurl = http://yum.mariadb.org/10.0/centos6-amd64
#gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
#gpgcheck=1
#x32 -------------------------------------------
#[mariadb] #name = MariaDB
#baseurl = http://yum.mariadb.org/5.5/centos6-x86
#gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
#gpgcheck=1 #[mariadb]
#name = MariaDB
#baseurl = http://yum.mariadb.org/10.0/centos6-x86
#gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
#gpgcheck=1

 

接著更新套件庫「sudo yum update

以我的例子來說他會要安裝
Transaction Summary
===========================
Install 3 Package(s)            MariaDB-compat.x86_64 0:5.5.41-1.el6、MariaDB-common.x86_64 0:5.5.41-1.el6、MariaDB-shared.x86_64 0:5.5.41-1.el6
Upgrade 1 Package(s)         java-1.7.0-openjdk.x86_64 1:1.7.0.75-2.5.4.0.el6_6

然後安裝  MarisDB 的 Server 與 Client
$ sudo yum -y install MariaDB-server MariaDB-client

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h people password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com

啟動服務與設定開機自動執行   // 對你沒看錯,就是以 mysql 的方式去啟動他(但名稱是  mysql 而不是 mysqld)
$sudo service mysql start
$sudo chkconfig mysql on

執行 MariaDB 初始化           // 這個過程也跟 Mysql 的一樣,只是最後會跟你說「Thanks for using MariaDB!」
$ /usr/bin/mysql_secure_installation 

以剛剛設定的 root 帳號登入,進行後續的設定
$ mysql -uroot -p

Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.41-MariaDB MariaDB Server
MariaDB [(none)]>use mysql;
MariaDB [mysql]> insert into user (host,user,password) values ('%','your_account',password('your_password'));
MariaDB [mysql]> GRANT ALL ON *.* TO 'your_account'@140.112.1.1 IDENTIFIED BY 'your_password' WITH GRANT OPTION;
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> quit

以 Navicat 登入,感覺上也跟使用 MySQL 無異

 

安裝真的還蠻簡單,但~~重點在於跟其他套件的配合(如 Wordpress、Xoops、Joomla、ECS....等),就繼續測試下去囉~~

~End

 

*****************************************************

繼續來把 LAMP 的環境裝完,只是這個 M 由 MySql 改成了 MariaDB ,我所測試的環境是先裝 MariaDB 後才裝 Apache 跟 PHP

sudo yum -y install httpd php php-mysql php-mbstring php-mcrypt php-gd php-xml

修改 ServerName
sudo vi /etc/httpd/conf/httpd.conf

啟動 httpd
$ sudo service httpd start
正在啟動 httpd: [ 確定 ]
$ sudo chkconfig httpd on

安裝 phpmyadmin   http://www.phpmyadmin.net/home_page/downloads.php  目前 YUM 套件為 4.0.10.7  ,官網的版本為 4.3.7。 phpmyadmin 被 try 的機率很高建議用最新版的。
$ wget  http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.3.7/phpMyAdmin-4.3.7-all-languages.tar.gz
mkdir ~/tmp; cd ~/tmp; tar zxvf ../phpMyAdmin-4.3.7-all-languages.tar.gz
$ mv phpMyAdmin-4.3.7-all-languages  /var/www/html/goddb         //這裡把 phpmyadmin 改成別的名稱是為了減少被攻擊、被 try 的機會
sudo restorecon -R -v /var/www/html/goddb                               // 設定 selinux 讓 goddb 可以被 apache/ httpd 存取 ,不改權限會得到 forbidden
restorecon reset /var/www/html/goddb/db_export.php context unconfined_u:object_r:user_home_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0


登入後,就可以對 MariaDB 進行操作、維護之動作。


~End2

*********************************************************

phpmyadmin 的 「設定檔案需要設定一組加密密碼 (blowfish_secret)」錯誤問題


這個是因為 blowfish_screct 會以 config.inc.php 內的 $cfg['blowfish_secret'] 作為 cookie 的加密密碼,而預設是空的
/* This is needed for cookie based authentication to encrypt password in cookie */
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

 

$ cd /var/www/html/goddb
$ sudo cp -p config.sample.inc.php  config.inc.php
可以把他改成 (給予一段文字當密碼)
   cfg['blowfish_secret'] = 'iamyourgrandma';

這樣就可以解決這個錯誤了。

回應
Google Search
Google
平均分數:0 顆星
投票人數:0
我要評分:
Google