Centos7.2使用yum安装MariaDB10.1

①添加MariaDB的yum源

1.创建MariaDB.repo

sudo vi /etc/yum.repos.d/Mariadb.repo

2.将以下文件中的字段添加到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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值