原文链接:http://www.cnblogs.com/zenghua/p/7149646.html
①添加MariaDB的yum源
1.创建MariaDB.repo
sudo vi /etc/yum.repos.d/Mariadb.repo
MariaDB 10.1 CentOS repository list - created 2016-12-01 03:36 UTC
http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
②yum安装MariaDB
sudo yum -y install MariaDB-server MariaDB-client
③启动MariaDB服务
systemctl start MysqL.service
④配置MariaDB服务
使用MysqL_secure_installation配置MariaDB服务
MysqL_secure_installation
具体设置
由于一开始安装MariaDB数据库后,root用户默认密码为空,所以只需要按Enter键
Enter current password for root (enter for none):
是否设置root用户的新密码
Set root password? [Y/n] y
录入新密码
New password:
确认新密码
Re-enter new password:
是否删除匿名用户,生产环境建议删除
Remove anonymous users? [Y/n] y
是否禁止root远程登录,根据自己的需求选择
Disallow root login remotely? [Y/n] n
是否删除test数据库
Remove test database and access to it? [Y/n] y
是否重新加载权限表
Reload privilege tables now? [Y/n] y
⑤开启远程访问
1.防火墙添加3306端口
查看firewall状态
firewall-cmd –state
状态是not running,启动firewall
systemctl start firewalld
状态是running
开放3306端口
firewall-cmd –zone=public –add-port=3306/tcp –permanent
重新载入
firewall-cmd –reload
2.明明之前有设置root开启远程的,但是我这里访问不了,所以重新去MariaDB赋权限
进入Mariadb
MysqL -uroot -p
选择数据库
use MysqL;
添加权限
Grant all on . to ‘root’@’%’ identified by ‘root用户的密码’ with grant option;
重新载入
flush privileges;
原文链接:https://www.f2er.com/centos/374483.html