centos安装mariadb数据库
0.准备工作
首先更新yum仓库
[root@piehost ~]# yum install https://centos7.iuscommunity.org/ius-release.rpm -y
1.移除mariadb-libs
[root@piehost ~]# yum remove -y mariadb-libs
2.添加yum仓库
[root@piehost ~]# yum install -y mariadb101u-server && systemctl start mariadb && systemctl enable mariadb
3.安装数据库,其中经过一些配置环节,包括输入密码
[root@piehost ~]# mysql_secure_installation
//安装数据库,其中经过一些配置环节,包括输入密码
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Thanks for using MariaDB!
4.进入mysql进行两项设置
[root@piehost ~]# mysql -uroot -p
//进入mysql
Enter password:
MariaDB [mysql]> update user set host = '%' where user ='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
//ctrl+d 退出mysql
MariaDB [mysql]> Bye
5.启动数据库,关闭防火墙,开放3306端口
[root@piehost ~]# systemctl start maridb //启动maridb
Failed to start maridb.service: Unit not found.
[root@piehost ~]# systemctl start mysql //启动mysql
Failed to start mysql.service: Unit not found.
[root@piehost ~]# setenforce 0
//关闭防火墙,0关;1关
[root@piehost ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
//开放防火墙
此时可以通过NavicatforMySQL连接你的数据库了