CentOS 7 MariaDB 10远程连接设置

时间:2019-07-03 21:57:24

标签: mariadb centos7

我一直在CentOS 07上设置MariaDB10。我很难弄清楚该怎么做才能与MariaDB数据库建立远程连接。我确实在/etc/my.cnf.d中添加了“ bind-address = 0.0.0.0”,MariaDB在添加后确实列出了端口3306。经历了许多不同的指南,但无法弄清我所缺少的内容。我唯一要注意的是,没有列出TCP4(仅列出TCP6)。谢谢您的帮助。

    [xxx]# sudo netstat -anp | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      32561/mysqld        


MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE 'PORT';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+


Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:587           0.0.0.0:*               LISTEN      4545/sendmail: acce 
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      20057/httpd         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      4487/sshd           
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      4545/sendmail: acce 
tcp        0      0 0.0.0.0:5308            0.0.0.0:*               LISTEN      4783/cfservd        
tcp6       0      0 :::3306                 :::*                    LISTEN      32561/mysqld        
tcp6       0      0 :::19091                :::*                    LISTEN      6434/macmnsvc      


[xxx]# firewall-cmd --add-port=3306/tcp 
Warning: ALREADY_ENABLED: '3306:tcp' already in 'public'
success
[root@xxxx# firewall-cmd --permanent --add-port=3306/tcp
Warning: ALREADY_ENABLED: 3306:tcp
success


MariaDB [(none)]> SELECT user, host FROM mysql.user;
+--------+------------------+
| User   | Host             |
+--------+------------------+
| bob | %                   |
| bob | [*local ip was here*].%    |
| mysql  | localhost        |
| root   | localhost        |
+--------+------------------+




vi /etc/my.cnf.d

#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.4 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.4]




[xxx]# telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
X
5.5.5-10.4.6-MariaDB
                    VOiAG#vN

0 个答案:

没有答案