mariadb数据库的安装以及安全初始化1

mariadb数据库的安装以及安全初始化



一、实验前提

实验环境:yum仓库搭建好
mariadb 是当前流行的Mysql数据库的分支
Mysql原先SUN公司(java)被Orical收购了
Mysql开源免费,所以企业当中的核心数据库是Orical,其余是Mysql
mariadb是Mysql数据库的一个分支


二、mariadb数据库的安装

1.数据库的安装

[root@server15 ~]# yum serach mariadb

在这里插入图片描述

[root@server15 yum.repos.d]# yum install mariadb-server.x86_64 -y
[root@server15 yum.repos.d]# rpm -ql mariadb-server 
查看它在系统里面安装的东西
/var/lib/mysql  其中这个为它的数据目录
/etc/my.cnf.d/server.cnf 主配置文件
/usr/lib/systemd/system/mariadb.service 服务的启动脚本
[root@server15 yum.repos.d]# systemctl enable --now mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
启动服务
[root@server15 yum.repos.d]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

三、mariadb数据库安全初始化

由于数据库的登陆不需要密码所以不安全,我们要安全初始化。


3.1 设定数据库基本的安全初始化

[root@server15 yum.repos.d]# mysql_secure_installation  初始化脚本
Enter current password for root (enter for none):   当前数据库管理员的密码,无密码直接回车
Set root password? [Y/n] Y                   设定数据库管理员密码
New password: 
Re-enter new password: 
Password updated successfully!
 ... Success!
Remove anonymous users? [Y/n] y   
 ... Success!         移除匿名用户登陆
Disallow root login remotely? [Y/n] y  
 ... Success!         移除管理员远程登陆
Remove test database and access to it? [Y/n] Y 
 ... Success!         移除测试库
Reload privilege tables now? [Y/n] y    
 ... Success!         刷新数据库

密码登陆

[root@server15 yum.repos.d]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> quit
Bye

默认情况下数据库对外开放端口,开放了,容易被攻击。一般在企业中要关闭

[root@server15 yum.repos.d]# netstat -antlupe | grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      27         31978      3768/mysqld     

3.2关闭对外开放端口

[root@server15 yum.repos.d]# vim /etc/my.cnf.d/server.cnf 
编辑主配置文件

在这里插入图片描述
关闭数据库网络端口

当设定完成后端口关闭

[root@server15 yum.repos.d]# systemctl restart mariadb.service 
[root@server15 yum.repos.d]# netstat -antlupe | grep mysql

END

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值