centos7 自帶了mariadbmysql
yum -y install mariadb mariadb-serversql
systemctl start mariadb數據庫
systemctl enable mariadbcentos
mysql_secure_installationtcp
Remove anonymous users? [Y/n] <– 是否刪除匿名用戶,回車 按yide
Disallow root login remotely? [Y/n] <–是否禁止root遠程登陸,回車, 按n測試
Remove test database and access to it? [Y/n] <– 是否刪除test數據庫,回車 按ycentos7
Reload privilege tables now? [Y/n] <– 是否從新加載權限表,回車 按 yspa
vi /etc/my.cnf3d
將下面這段內容加入
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%";
在任意位置執行下面的命令
firewall-cmd --state
systemctl start firewalld.service
systemctl enable firewalld.service
firewall-cmd --list-all
firewall-cmd --zone=public --add-port=3306/tcp --permanent
登陸成功後執行
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
完成