CentOS 7 安装 mariaDB

1、安装数据库

[root@localhost ~]# yum -y  install mariadb-server mariadb mariadb-devel

2、启动数据库
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb

3、开通防火墙
[root@localhost ~]# firewall-cmd --permanent --add-service mysql
[root@localhost ~]# systemctl restart firewalld.service
[root@localhost ~]# iptables -L -n|grep 3306

4、修改root用户的密码以及打开远程连接
[root@localhost ~]# mysql -uroot -p

Enter password:                                //密码默认为空,回车即可
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.50-MariaDB MariaDB Server

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

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

MariaDB [(none)]> show databases;

MariaDB [(none)]> use mysql

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";

MariaDB [mysql]> update user set Password = password('123') where User='root';

MariaDB [mysql]> flush privileges;       //使设置生效

扩展阅读:

systemctl是RHEL7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。可以使用它永久性或只在当前会话中启用/禁用服务。
启动一个服务:systemctl start postfix.service
关闭一个服务:systemctl stop postfix.service
重启一个服务:systemctl restart postfix.service
显示一个服务的状态:systemctl status postfix.service
在开机时启用一个服务:systemctl enable postfix.service
在开机时禁用一个服务:systemctl disable postfix.service
查看服务是否开机启动:systemctl is-enabled postfix.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

显示权限:ls -lh  
设置目录的所有人(u)、群组(g)以及其他人(o)以读(r )、写(w)和执行(x)的权限:chmod 777 directory1  
删除群组(g)与其他人(o)对目录的读写执行权限:chmod 700 directory1  
改变一个文件file1的所有人属性为use1:chown user1 file1  
改变一个目录的所有人属性并同时改变改目录下所有文件的属性都为use1所有:chown -R user1 directory1 

查看磁盘空间大小:

# df -h
# fdisk -l

原文地址:https://www.cnblogs.com/101key/p/6112270.html