1. centos7 中安装mariadb
1.1 执行安装
centos7 自带了mariadb
yum -y install mariadb mariadb-server
1.2 启动mariadb
systemctl start mariadb
1.3 设置开机启动
systemctl enable mariadb
1.4 MariaDB的相关简单配置
mysql_secure_installation
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车 按y
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车, 按n
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车 按y
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车 按 y
1.5 配置MariaDB的字符集
vi /etc/my.cnf
将下面这段内容加入
init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake |
在[client]中添加
vi /etc/my.cnf.d/client.cnf
default-character-set=utf8
在[mysql]中添加
vi /etc/my.cnf.d/mysql-clients.cnf
default-character-set=utf8
全部配置完成,重启mariadb
systemctl restart mariadb;
登陆之后进入MariaDB查看字符集
show variables like "%character%";show variables like "%collation%";
1.6 设置防火墙
1.6.1 查看防火墙状态
在任意位置执行下面的命令
firewall-cmd --state
1.6.2 立即开启防火墙
systemctl start firewalld.service
1.6.3 开启开机启动防火墙
systemctl enable firewalld.service
1.6.4 查看开启的端口
firewall-cmd --list-all
1.6.5 开启需要的端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
1.7 外界连接授权
登录成功后执行
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
1.8 测试外界连接
完成