我经历了很多教程和问题,但仍然无法实现。
我去过:
我在Ubuntu 16.04上安装了MariaDB。 然后设置两个用户,其中一个用于公共使用,所以我可以在这里发布。
用户添加为:
CREATE USER 'anon'@'%' IDENTIFIED BY '';
本地连接是否工作?
是的,我可以通过服务器上的ssh作为用户连接:
mysql -u anon
你确认用户是否被正确添加了?
我想是这样:
MariaDB [(none)]> SELECT User, Host FROM mysql.user WHERE Host <> 'localhost'; +------+------+ | User | Host | +------+------+ | anon | % | | user | % | +------+------+ 2 rows in set (0.01 sec)
你打开防火墙吗?
可能需要解锁防火墙:
[user]@popfreq:/etc/mysql$ firewall-cmd --add-port=3306/tcp The program 'firewall-cmd' is currently not installed. You can install it by typing: sudo apt install firewalld
防火墙未安装。
你检查my.cnf文件的正确设置?
my.cnf ( [user]@popfreq:/etc/mysql )中的错误设置会导致拒绝连接。 这些是skip-networking和bind-address 。 我的文件看起来像这样:
# The MariaDB configuration file # # The MariaDB/MySQL tools read configuration files in the following order: # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, # 2. "/etc/mysql/conf.d/*.cnf" to set global options. # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. # 4. "~/.my.cnf" to set user-specific options. # # If the same option is defined multiple times, the last one will apply. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # This group is read both both by the client and the server # use it for options that affect everything # [client-server] # Import all .cnf files from configuration directory !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mariadb.conf.d/
它根本没有违规的路线。
你检查了其他的configuration文件吗?
是。 他们也没有违规的线路。
telnet工作吗?
没有。
mint@mint-VirtualBox ~ $ telnet 128.199.203.208 3306 Trying 128.199.203.208... telnet: Unable to connect to remote host: Connection refused
不知道这意味着什么或如何解决。
服务器使用什么接口?
似乎只有本地人:
[user]@popfreq:/etc/mysql/mariadb.conf.d$ sudo netstat -ntlup | grep mysql tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 16884/mysqld
你记得重新启动吗? 是。 我在所有的尝试之间重新使用这个:
sudo service mysql restart
在我的情况下,错误的解决scheme是在my.cnfconfiguration文件中根本没有[mysqld]部分。 添加这个解决了这个问题:
[mysqld] bind-address = ::
不知道为什么它没有被默认添加。 请注意,使用:: over 0.0.0.0的原因是::适用于IPv6( 在mySQL手册中提到 ,但不是在mariaDB手册中提到 )。
这也固定了telnet:
mint@mint-VirtualBox ~ $ telnet 128.199.203.208 3306 Trying 128.199.203.208... Connected to 128.199.203.208.
networking输出现在是:
[user]@popfreq:/etc/mysql$ sudo netstat -ntlup | grep mysql tcp6 0 0 :::3306 :::* LISTEN 17609/mysqld
希望这可以帮助别人。