MariaDB 安装

MariaDB 数据库管理系统是 MySQL 的一个分支,主要由开源社区在维护,采用 GPL 授权许可。开发这个分支的原因之一是:甲骨文公司收购了 MySQL 后,有将 MySQL 闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB完全兼容mysql,使用方法也是一样的.有的centos7已经默认安装了Mariadb,可以查看自己的有没有安装,没有安装的再进行安装,已经安装了可以不用安装也可以卸载了重装。卸载命令

yum remove mariadb-server
[root@CentOS ~]# cat  /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

CentOS7 下载路径 http://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1908.iso

1、安装MariaDB

通过yum安装就行了。简单快捷,安装mariadb-server,默认依赖安装mariadb,一个是服务端、一个是客户端。

[root@CentOS ~]# yum install mariadb-server

2、配置MariaDB

1)安装完成后首先要把MariaDB服务开启,并设置为开机启动

[root@CentOS ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@CentOS ~]# systemctl start mariadb
[root@CentOS ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since 四 2020-01-09 13:11:39 CST; 2s ago
  Process: 1582 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 1495 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 1581 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─1581 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─1743 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql...

1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: MySQL manual for more i...
1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: Please report any probl...
1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: The latest information ...
1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: You can find additional...
1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: http://dev.mysql.com
1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: Consider joining MariaD...
1月 09 13:11:37 CentOS mariadb-prepare-db-dir[1495]: https://mariadb.org/get...
1月 09 13:11:37 CentOS mysqld_safe[1581]: 200109 13:11:37 mysqld_safe Loggi....
1月 09 13:11:37 CentOS mysqld_safe[1581]: 200109 13:11:37 mysqld_safe Start...l
1月 09 13:11:39 CentOS systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@CentOS ~]# systemctl enable mariadb 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

2)首次安装需要进行数据库的配置,命令都和mysql的一样

[root@CentOS ~]# mysql_secure_installation

3)配置时出现的各个选项

[root@CentOS ~]# 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] n
 ... skipping.

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] n
 ... skipping.

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!

4)测试是否能够登录成功,并开启远程访问权限!

[root@CentOS ~]# mysql -u root -proot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.64-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)]> use user
ERROR 1049 (42000): Unknown database 'user'
MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]>
  1. 检查防火墙
[root@CentOS ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 四 2020-01-09 13:04:42 CST; 12min ago
     Docs: man:firewalld(1)
 Main PID: 743 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─743 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

1月 09 13:04:41 CentOS systemd[1]: Starting firewalld - dynamic firewall d.....
1月 09 13:04:42 CentOS systemd[1]: Started firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@CentOS ~]# systemctl stop firewalld
[root@CentOS ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 四 2020-01-09 13:17:35 CST; 2s ago
     Docs: man:firewalld(1)
  Process: 743 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 743 (code=exited, status=0/SUCCESS)

1月 09 13:04:41 CentOS systemd[1]: Starting firewalld - dynamic firewall d.....
1月 09 13:04:42 CentOS systemd[1]: Started firewalld - dynamic firewall daemon.
1月 09 13:17:35 CentOS systemd[1]: Stopping firewalld - dynamic firewall d.....
1月 09 13:17:35 CentOS systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@CentOS ~]# firewall-cmd --state
not running
[root@CentOS ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值