配置目录库

1

2

touch /etc/yum.repos.d/mariadb.repo

直接使用 vim /etc/yum.repos.d/mariadb.repo 也是可以的

写入以下命令

1

2

3

4

5

[mariadb]

name = MariaDB

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

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

gpgcheck=1

1

2

3

4

5

[mariadb]

name=Mariadb

baseurl=https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5/centos74-amd64/

gpgcheck=1

gpgkey=https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB

通过yum安装

1

yum install mariaDB-server mariaDB-client -y

开机自启动

1

systemctl enable mariadb   开机启动mariadb

初始化

1

mysql_secure_installation

修改/etc/my.cnf

1

2

3

[mysqld]

character-set-server=utf8

collation-server=utf8_general_ci

重启服务mariadb

1

systemctl restart mariadb

登录mariadb

1

mysql -uroot -proot

授权远程

1

2

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;

flush privileges;

最后要关闭防火墙

1

service firewalld stop;setenforce 0

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐