Linux-Mariadb yum安裝

1.修改系統(tǒng)自帶yum源為阿里yum源

cd /etc/yum.repos.d
mkdir bak
mv CentOS* ./bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

2.卸載Centos系統(tǒng)自帶的低版本Mariadb數(shù)據(jù)庫

yum remove mariadb-*

3.創(chuàng)建Mariadb數(shù)據(jù)庫的yum倉庫

在目錄下 /etc/yum.repos.d/ 創(chuàng)建文件: MariaDB.repo
vim /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.4/centos7-amd64/
gpgkey =  http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

4.清楚yum緩存并重新建立yum庫

yum clean all
yum makecache

5.安裝MariaDB數(shù)據(jù)庫

yum install MariaDB-client MariaDB-server MariaDB-devel -y

6.修改數(shù)據(jù)庫配置文件

vi /etc/my.cnf.d/server.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-external-locking
#innodb_autoinc_lock_mode=0
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# 并發(fā)線程數(shù),建議為CPU核心數(shù)乘以2:  CPU's*2 for thread_concurrency
thread_concurrency = 8
innodb_purge_threads = 8
max_connections=200

7.啟動Mariadb數(shù)據(jù)庫并設(shè)為開機自啟

systemctl start mariadb
systemctl enable mariadb

8.初始化Mariadb數(shù)據(jù)庫

/usr/bin/mysql_secure_installation
Enter current password for root (enter for none): Just press the Enter button    //回車
Set root password? [Y/n]: Y     //設(shè)置root密碼
New password: your-MariaDB-root-password
Re-enter new password: your-MariaDB-root-password
Remove anonymous users? [Y/n]: Y       //刪除初始用戶
Disallow root login remotely? [Y/n]: n       //禁止root遠程登錄
Remove test database and access to it? [Y/n]: Y      //刪除test庫
Reload privilege tables now? [Y/n]: Y           //刷新表
//初始化完成后重啟數(shù)據(jù)庫

8.附帶Mariadb數(shù)據(jù)庫壓力測試命令

mysqlslap -a -c 500 -i 10 -uroot -p

9.數(shù)據(jù)庫用戶授權(quán)命令

grant all on *.* to 'test_1'@'localhost' identified by '123456';
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容