CentOS 7 - MariaDB

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。

MariaDB服务

查询MariaDB

yum info mariadb
yum info mariadb-server

安装和配置MariaDB服务

yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
mysql_secure_installation
# Follow the instruction ... ...

查询socket statistics状态(TCP 3306)

ss -antp | grep mysqld

配置防火墙例外

firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload
firewall-cmd --list-services

数据库维护

基本操作

mysql -u root -p
create database myDB;
show databases;
grant all privileges on myDB.* to myDBowner@'%' identified by 'MyPassword';
grant select on myDB.* to myDBread@'%' identified by 'MyPassword';
flush privileges;
show grants for myDBowner;

备份数据库

mkdir /backup
mysqldump -uroot -pMyPassword myDB | gzip > /backup/myDB.sql.gz
ls /backup

恢复数据库

cd /backup
gunzip myDB.sql.gz
ls
cat myDB.sql | mysql -uroot -pMyPassword myDB

备份数据库脚本

#/bin/bash
sub_folder=$(date +%Y%m%d)
cd /backup
mkdir $sub_folder
backup_file=/backup/$sub_folder/myDB.sql.gz
mysqldump -uroot -pMyPassword myDB | gzip > $backup_file

MariaDB 10.1数据库连结问题(高版本)

报错:Host is not allowed to connect to this MariaDB server

 UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND host = 'localhost';

安装phpMyAdmin

# 安装Apache
yum install httpd -y
systemctl status httpd
systemctl start httpd
systemctl enable httpd
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
firewall-cmd --list-service
# 安装phpMyAdmin
yum install epel-release -y
yum install phpmyadmin -y

访问http://xxx.xxx.xxx.xxx/phpMyAdmin

报错:You don't have permission to access /phpmyadmin on this server.

修改配置文件vi /etc/httpd/conf.d/phpMyAdmin.conf

Require ip 127.0.0.1 192.168.10.100
# 允许192.168.10.100通过Web访问和配置MariaDB服务器

重启httpd服务

systemctl restart httpd