CentOS-6上安裝二進位Mariadb

來源:互聯網
上載者:User

標籤:mariadb

前言:

    mariadb官方網站上提供了三種不同形式的程式包:源碼包版、封裝管理員版、和二進位版,如所示。二進位版是由官方編譯好的綠色版,相比源碼包版安裝更簡單,比起封裝管理員版又多一點自由度,算是二者的折中方案。另外要注意它依賴於glibc,需要注意glibc的版本。

安裝:

步驟一:

首先確認glibc版本,可以看到CentOS-6上安裝的是glibc-2.12版,所以需要下載

# rpm -q glibcglibc-2.12-1.166.el6.x86_64

步驟二:

關閉iptables和SElinux


步驟三: 

# 建立系統使用者mysql

# useradd -r mysql

# 解壓至目錄/usr/local/

# tar -xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/

# 建立軟連結mysql

# cd /usr/local/# ln -sv mariadb-5.5.43-linux-x86_64/ mysql"mysql" -> "mariadb-5.5.43-linux-x86_64/"

# 修改目錄屬主和屬組

# chown -R root:mysql .

# 建立資料庫目錄。如果不單獨建立並指定則預設使用目前的目錄下的data目錄作為資料庫目錄

# mkdir -pv /data/mysqlmkdir: created directory `/data‘mkdir: created directory `/data/mysql‘

# 修改資料庫目錄的屬主和屬組為mysql

# chown -R mysql:mysql /data/mysql/

# 安裝資料庫

# scripts/mysql_install_db --user=mysql --datadir=/data/mysql


配置

# 將bin目錄路徑匯入PATH環境變數

# vim /etc/profile.d/mysql.shexport PATH=/usr/local/mysql/bin:$PATH

# 立即生效

# exec bash

# 建立標頭檔符號連結

# cd /usr/local/include/# ln -s ../mysql/include/mysql/ mysql

# 將man路徑匯入系統man手冊

# vim /etc/man.configMANPATH /usr/local/mysql/man

# 拷貝服務指令碼至/etc/rc.d/init.d目錄

# cd /usr/local/mysql# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

# 複製模板設定檔至/etc/目錄

# cp support-files/my-large.cnf /etc/my.cnf

# 修改設定檔

# vim /etc/my.cnf

字元集:

        mysqld為服務端,mysql為本地cli命令列工具,client為用戶端串連工具包括遠端連線工具等。均需要將字元集統一設定為utf-8,特殊情境根據實際情況修改為其他字元集。

[client]default-charater-set=utf8[mysql]default-charater-set=utf8[mysqld]character-set-server=utf8


字元排序:

[mysqld]collation-server=utf8_general_ci


資料庫目錄

[mysqld]datadir=/data/mysql


儲存引擎

[mysqld]# 預設使用innodb儲存引擎default-storage-engine=InnoDB# 每張表都使用獨立資料表空間innodb-file-per-table=TRUE


關閉網域名稱反解

skip-name-resolve=TRUE


配置完成後應該是這個樣子

[client]port            = 3306socket          = /tmp/mysql.sockdefault-character-set=utf8[mysqld]datadir=/data/mysqlport            = 3306socket          = /tmp/mysql.sockskip-external-lockingkey_buffer_size = 256Mmax_allowed_packet = 1Mtable_open_cache = 256sort_buffer_size = 1Mread_buffer_size = 1Mread_rnd_buffer_size = 4Mmyisam_sort_buffer_size = 64Mthread_cache_size = 8query_cache_size= 16Mthread_concurrency = 8character-set-server=utf8collation-server=utf8_general_cidefault-storage-engine=InnoDBinnodb-file-per-table=TRUEskip-name-resolve=TRUElog-bin=mysql-binskip-name-resolve=TRUElog-bin=mysql-binbinlog_format=mixedserver-id       = 1[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehashdefault-character-set=utf8[myisamchk]key_buffer_size = 128Msort_buffer_size = 128Mread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout


啟動服務

/etc/init.d/mysqld start

開機自啟動

chkconfig --add mysqldchkconfig mysqld on

安全設定

# mysql_secure_installation /usr/local/mysql/bin/mysql_secure_installation: line 379: find_mysql_client: command not foundNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we‘ll need the currentpassword for the root user.  If you‘ve just installed MariaDB, andyou haven‘t set the root password yet, the password will be blank,so you should just press enter here.# 初始root密碼為空白,直接斷行符號Enter current password for root (enter for none): OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.#設定root密碼Set root password? [Y/n] n ... skipping.By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.# 刪除匿名使用者Remove anonymous users? [Y/n] n ... skipping.Normally, root should only be allowed to connect from ‘localhost‘.  Thisensures that someone cannot guess at the root password from the network.# 不允許root遠程登陸Disallow root login remotely? [Y/n] n ... skipping.By default, MariaDB comes with a database named ‘test‘ that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.# 刪除test資料庫以及訪問它的使用權限設定Remove test database and access to it? [Y/n] n ... skipping.Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.# 重載許可權列表Reload privilege tables now? [Y/n] y ... Success!Cleaning up...All done!  If you‘ve completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!


CentOS-6上安裝二進位Mariadb

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.