/ Linux

Linux CentOS 7安装MariaDB

  • 操作系统:CentOS Linux release 7.0.1406 (Core)
  • 安装工具:yum

执行安装命令,部分依赖会自动安装
yum install -y MariaDB-server
如果想安装其他MariaDB模块,可以使用命令进行搜索,看自己的需要安装
yum search MariaDB*
安装完成后设置“现在启动”和“开机启动”

systemctl enable mariadb  //开机启动<br></br>
systemctl start mariadb  //现在启动<br></br>
systemctl status mariadb  //查看运行状态```
  
 设置MariaDB,执行命令  
`mysql_secure_installation`  
 会出现下面的提示:输入root密码。如果是新安装的MariaDB是没有密码的,所以直接按“回车键”,表示空密码  

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):```

是否设置新密码:按y并回车,然后输入两次新密码

Setting the root password ensures that nobody can log into the MariaDB<br></br>
root user without the proper authorisation.<br></br>
Set root password? [Y/n]```
  
 是否移除匿名用户:按y并回车  

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]```

是否不允许root用户的远程登录:按y并回车。为了安全,建议不允许远程登录,同时安装完成后修改root用户的用户名

Normally, root should only be allowed to connect from 'localhost'.  This<br></br>
ensures that someone cannot guess at the root password from the network.<br></br>
Disallow root login remotely? [Y/n]```
  
 是否移除测试数据库和对它的访问权限:按y并回车  

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]

<br></br>
是否现在重新载入授权表:按y并回车<br></br>
Reloading the privilege tables will ensure that all changes made so far<br></br>
will take effect immediately.<br></br>
Reload privilege tables now? [Y/n]```
  
 使用命令登录到MariaDB试试:  

mysql -u root -p //回车后输入用户密码


Enter password:


......


MariaDB [(none)]>

```

到此基本安装成功。