centos7 安装 mariadb数据库

19 篇文章 0 订阅
16 篇文章 1 订阅

1、配置 yum 源

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

   写入数据。本次安装的 mariadb 版本为 10.11

阿里镜像地址为: 阿里镜像 mariadb-yum安装包下载_开源镜像站-阿里云

[mariadb]
name=MariaDB
baseurl=https://mirrors.aliyun.com/mariadb/yum/10.11/centos7-amd64/
gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1

2、yum 安装 

yum install  -y mariadb-server

3、检查安装情况

[root@abc]# rpm -qa |grep -i mariadb
MariaDB-common-10.11.1-1.el7.centos.x86_64
MariaDB-compat-10.11.1-1.el7.centos.x86_64
MariaDB-client-10.11.1-1.el7.centos.x86_64
MariaDB-server-10.11.1-1.el7.centos.x86_64

或者查看 mariadb 的版本号

mariadb --version
mariadb  Ver 15.1 Distrib 10.11.1-MariaDB, for Linux (x86_64) using readline 5.1

4、开启服务/加入开机自启

1、加入开机自启
systemctl enable mariadb

2、启动服务
systemctl start mariadb

 5、数据库初始化

[root@abc /]mysql_secure_installation
-bash: mysql_secure_installation: command not found

执行上面数据库初始化后,报错,查阅资料后发现,从10.5.2开始已经由

mariadb-secure-installation命令替换

mariadb-secure-installation
[root@beian /]# mariadb-secure-installation

Enter current password for root (enter for none): -- 直接回车 
OK, successfully used password, moving on...

Switch to unix_socket authentication [Y/n] n -- 输入 n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y  -- 输入 y -- 设置 root 密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y       
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

6、进入数据库,设置远程账号

1、进入数据库
[root@abc /]# mysql -uroot -p
Enter password: 

2、设置远程登录账号
MariaDB [(none)]> grant all on *.* to 'test'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.084 sec)

3、刷新配置
flush privileges;


grant all on *.* to 'test'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.084 sec)
flush privileges;

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值