CentOS7下安裝Mariadb 10.3.17

1. install lsb package
sudo yum install -y redhat-lsb

2.install net-tools package
sudo yum install -y net-tools

3.關閉selinux設置機器名
sudo setenforce 0
sudo vi /etc/selinux/config 下的 SELINUX=disabled
sudo /usr/sbin/sestatus -v
hostnamectl set-hostname db-publicCloud
能夠選擇重啓機器。

4. 配置 MariaDB 10.3 yum
sudo vi /etc/yum.repos.d/MariaDB.repo

# MariaDB 10.3 CentOS repository list - created 2018-06-01 02:02 UTC

# http://downloads.mariadb.org/mariadb/repositories/

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.3/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1


5. yum安裝MariaDB

sudo yum -y install MariaDB-server MariaDB-client

6.修改密碼,設置遠程登錄
mysqladmin -u root password "123456ABCD!@#$%^"
mysql_secure_installation

7.登陸mysql,修改權限,建立用戶
GRANT ALL PRIVILEGES ON *.* TO 'publicCloud'@'%' IDENTIFIED BY '123456ABCD!@#$%^' WITH GRANT OPTION;
FLUSH PRIVILEGES;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456ABCD!@#$%^' WITH GRANT OPTION;
FLUSH PRIVILEGES;

8.修改默認文件配置
systemctl start mariadb

#修改mariadb的配置文件
sudo vim /etc/my.cnf.d/server.cnf

[mysqld]

datadir=/home/mariadb
slow_query_log=on
slow_query_log_file=/home/mariadb/slow_query_log.log
long_query_time=10
max_allowed_packet=512M
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
lower_case_table_names=0


9.建立文件夾
mkdir /home/mariadb

10.備份文件
cp -R  /var/lib/mysql/mysql  /var/lib/mysql/mysql.bak_20190910
cp -R /var/lib/mysql/* /home/mariadb/

sudo chown -R mysql:mysql /home/mariadb
chmod 755 -R /home/mariadb

11.修改service文件
vim /usr/lib/systemd/system/mariadb.service
[service]
ProtectHome=false



11.啓動mariadb並登陸
systemctl start mariadb





mysql

相關文章
相關標籤/搜索