您好,登錄后才能下訂單哦!
前言:
mariadb官方網(wǎng)站上提供了三種不同形式的程序包:源碼包版、程序包管理器版、和二進(jìn)制版,如下圖所示。二進(jìn)制版是由官方編譯好的綠色版,相比源碼包版安裝更簡單,比起程序包管理器版又多一點(diǎn)自由度,算是二者的折中方案。另外要注意它依賴于glibc,需要注意glibc的版本。
安裝:
步驟一:
首先確認(rèn)glibc版本,可以看到CentOS-6上安裝的是glibc-2.12版,所以需要下載
# rpm -q glibc glibc-2.12-1.166.el6.x86_64
步驟二:
關(guān)閉iptables和SElinux
步驟三:
# 創(chuàng)建系統(tǒng)用戶mysql
# useradd -r mysql
# 解壓至目錄/usr/local/
# tar -xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/
# 創(chuàng)建軟鏈接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 .
# 創(chuàng)建數(shù)據(jù)庫目錄。如果不單獨(dú)創(chuàng)建并指定則默認(rèn)使用當(dāng)前目錄下的data目錄作為數(shù)據(jù)庫目錄
# mkdir -pv /data/mysql mkdir: created directory `/data' mkdir: created directory `/data/mysql'
# 修改數(shù)據(jù)庫目錄的屬主和屬組為mysql
# chown -R mysql:mysql /data/mysql/
# 安裝數(shù)據(jù)庫
# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
配置
# 將bin目錄路徑導(dǎo)入PATH環(huán)境變量
# vim /etc/profile.d/mysql.sh export PATH=/usr/local/mysql/bin:$PATH
# 立即生效
# exec bash
# 創(chuàng)建頭文件符號(hào)鏈接
# cd /usr/local/include/ # ln -s ../mysql/include/mysql/ mysql
# 將man路徑導(dǎo)入系統(tǒng)man手冊(cè)
# vim /etc/man.config MANPATH /usr/local/mysql/man
# 拷貝服務(wù)腳本至/etc/rc.d/init.d目錄
# cd /usr/local/mysql # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# 復(fù)制模板配置文件至/etc/目錄
# cp support-files/my-large.cnf /etc/my.cnf
# 修改配置文件
# vim /etc/my.cnf
字符集:
mysqld為服務(wù)端,mysql為本地cli命令行工具,client為客戶端連接工具包括遠(yuǎn)程連接工具等。均需要將字符集統(tǒng)一設(shè)置為utf-8,特殊場(chǎng)景根據(jù)實(shí)際情況修改為其他字符集。
[client] default-charater-set=utf8 [mysql] default-charater-set=utf8 [mysqld] character-set-server=utf8
字符排序:
[mysqld] collation-server=utf8_general_ci
數(shù)據(jù)庫目錄
[mysqld] datadir=/data/mysql
存儲(chǔ)引擎
[mysqld] # 默認(rèn)使用innodb存儲(chǔ)引擎 default-storage-engine=InnoDB # 每張表都使用獨(dú)立表空間 innodb-file-per-table=TRUE
關(guān)閉域名反解
skip-name-resolve=TRUE
配置完成后應(yīng)該是這個(gè)樣子
[client] port = 3306 socket = /tmp/mysql.sock default-character-set=utf8 [mysqld] datadir=/data/mysql port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 256M max_allowed_packet = 1M table_open_cache = 256 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size= 16M thread_concurrency = 8 character-set-server=utf8 collation-server=utf8_general_ci default-storage-engine=InnoDB innodb-file-per-table=TRUE skip-name-resolve=TRUE log-bin=mysql-bin skip-name-resolve=TRUE log-bin=mysql-bin binlog_format=mixed server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash default-character-set=utf8 [myisamchk] key_buffer_size = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout
啟動(dòng)服務(wù)
/etc/init.d/mysqld start
開機(jī)自啟動(dòng)
chkconfig --add mysqld chkconfig mysqld on
安全設(shè)置
# mysql_secure_installation /usr/local/mysql/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: 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 current password for the root user. If you've just installed MariaDB, and you 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 MariaDB root user without the proper authorisation. #設(shè)置root密碼 Set root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. # 刪除匿名用戶 Remove anonymous users? [Y/n] n ... skipping. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. # 不允許root遠(yuǎn)程登陸 Disallow root login remotely? [Y/n] n ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. # 刪除test數(shù)據(jù)庫以及訪問它的權(quán)限設(shè)置 Remove test database and access to it? [Y/n] n ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. # 重載權(quán)限列表 Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。