一、实验环境:

  系统:CentOS7.6,关闭了防火墙与SELINUX

  数据库版本:mariadb-10.2.25(二进制安装与源码安装)

二、安装方法:

1、yum源安装

 (1) 配置yum源,官方yum源下载太慢,用国内的镜像源吧

[root@centos7 ~]# cat /etc/yum.repos.d/mariadb.repo 
# MariaDB 10.2 CentOS repository list - created 2019-11-29 02:18 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.2/centos7-amd64/
gpgcheck=0

 (2) 开始安装

[root@centos7 ~]# yum install -y MariaDB-server MariaDB-client

 (3) 启动服务

[root@centos7 ~]# systemctl start mariadb
[root@centos7 ~]# ss -nlt
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128               *:111                           *:*                  
LISTEN     0      128               *:6000                          *:*                  
LISTEN     0      5      192.168.122.1:53                            *:*                  
LISTEN     0      128               *:22                            *:*                  
LISTEN     0      128       127.0.0.1:631                           *:*                  
LISTEN     0      100       127.0.0.1:25                            *:*                  
LISTEN     0      80               :::3306                         :::*                  
LISTEN     0      128              :::111                          :::*                  
LISTEN     0      128              :::6000                         :::*                  
LISTEN     0      128              :::22                           :::*                  
LISTEN     0      128             ::1:631                          :::*                  
LISTEN     0      100             ::1:25                           :::*                  
[root@centos7 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.29-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)]> 

 (4) 设置mysql密码,可以用/usr/bin/mysqladmin -u root password 'new-password' 设置,或使用安全脚本设置,以下为用脚本设置

[root@centos7 ~]# /usr/bin/mysql_secure_installation 
#使用脚本交互式设置
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

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!
View Code

相关文章:

  • 2022-12-23
  • 2021-10-02
  • 2021-07-04
  • 2021-12-13
  • 2021-07-23
  • 2021-09-10
  • 2022-01-02
  • 2022-12-23
猜你喜欢
  • 2021-10-02
  • 2021-09-06
  • 2022-12-23
  • 2021-12-18
  • 2021-09-29
  • 2021-11-06
  • 2022-12-23
相关资源
相似解决方案