/--- date: 2017-05-21 22:15:43 +0800 categories: 技术 ---/

LEMP环境搭建(四)MariaDB

yum安装

yum install mariadb-server

systemctl enable mariadb.service
systemctl start mariadb.service
systemctl status mariadb.service

mysql_secure_installation

# 如需要,防火墙开启端口
firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload
firewall-cmd --list-all

配置

mysql -u root -p

# 创建用户,并增加对应库的增删改查权限
MariaDB [(none)]> CREATE DATABASE wesaid;
MariaDB [(none)]> CREATE USER 'wesaid'@'localhost' IDENTIFIED BY 'wesaid.mariadb';
MariaDB [(none)]> GRANT SELECT,INSERT,UPDATE,DELETE ON wesaid.* To 'wesaid'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> SHOW GRANTS FOR 'wesaid'@'localhost';

# 如需要,开启远程访问权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.211.55.%' IDENTIFIED BY 'mariadb' WITH GRANT OPTION;
MariaDB [(none)]> SELECT User, Host FROM mysql.user WHERE Host <> 'localhost';

附1:参考

https://www.vultr.com/docs/install-mariadb-on-centos-7 http://www.linuxea.com/1017.html https://mariadb.com/kb/zh-cn/configuring-mariadb-for-remote-client-access/