MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。
MariaDB服务
查询MariaDB
<code>yum info mariadbyum info mariadb-server/<code>
安装和配置MariaDB服务
<code>yum install mariadb-server -ysystemctl start mariadbsystemctl enable mariadbsystemctl status mariadbmysql_secure_installation# Follow the instruction ... .../<code>
查询socket statistics状态(TCP 3306)
<code>ss -antp | grep mysqld/<code>
配置防火墙例外
<code>firewall-cmd --permanent --add-service=mysqlfirewall-cmd --reloadfirewall-cmd --list-services/<code>
数据库维护
基本操作
<code>mysql -u root -pcreate 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;/<code>
备份数据库
<code>mkdir /backupmysqldump -uroot -pMyPassword myDB | gzip > /backup/myDB.sql.gzls /backup/<code>
恢复数据库
<code>cd /backupgunzip myDB.sql.gzlscat myDB.sql | mysql -uroot -pMyPassword myDB/<code>
备份数据库脚本
<code>#/bin/bashsub_folder=$(date +%Y%m%d)cd /backupmkdir $sub_folderbackup_file=/backup/$sub_folder/myDB.sql.gzmysqldump -uroot -pMyPassword myDB | gzip > $backup_file/<code>
MariaDB 10.1数据库连结问题(高版本)
报错:Host is not allowed to connect to this MariaDB server
<code> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND host = 'localhost';/<code>
安装phpMyAdmin
<code># 安装Apacheyum install httpd -ysystemctl status httpdsystemctl start httpdsystemctl enable httpdfirewall-cmd --permanent --add-service=httpfirewall-cmd --reloadfirewall-cmd --list-service# 安装phpMyAdminyum install epel-release -yyum install phpmyadmin -y/<code>
访问http://xxx.xxx.xxx.xxx/phpMyAdmin
报错:You don't have permission to access /phpmyadmin on this server.
修改配置文件vi /etc/httpd/conf.d/phpMyAdmin.conf
<code>Require ip 127.0.0.1 192.168.10.100# 允许192.168.10.100通过Web访问和配置MariaDB服务器/<code>
重启httpd服务
<code>systemctl restart httpd/<code>
閱讀更多 alphabook 的文章