MariaDB
From AlphaBook
Contents
Install
- yum info mariadb-server
- yum install mariadb-server -y
Configure Service
- systemctl start mariadb
- systemctl enable mariadb
- systemctl status mariadb
- mysql_secure_installation
Configure Firewall (TCP 3306)
- firewall-cmd --permanent --add-service=mysql
- firewall-cmd --pernament --reload
- firewall-cmd --list-services
- firewall-cmd --pernament --add-rich-rule='rule family=ipv4 source address=192.168.1.100 service name=mysql accept'
Database Operation
- cat /etc/my.cnf
- log-error=/var/log/mariadb/mariadb.log
- mysql -u root -p
- show databases;
- create database Test;
- drop database Test;
- create database myDB;
- grant all privileges on myDB.* to myDBower@'%' identified by '123.com';
- grant select on myDB.* to myDBread@'%' identified by '123.com';
- flush privileges;
Backup and Restore
- mysqldump -uroot -p123.com myDB | gzip >> /backup/myDB.sql.gz
- gunzip /backup/myDB.sql.gz
- cat /backup/myDB.sql | mysql -uroot -p123.com myDB