装好 MariaDB 后,并不能直接从 Windows 主机访问,需要打开一定权限。我们需要修改配置文件以开放本地“远程”访问。
配置文件的目录是/etc/mysql/mariadb.conf.d/50-server.cnf
。
找到该文件Basic Settings
部分,修改bind-adress
的值为0.0.0.0
(下方代码中最后一行),以开放权限给本机上的其他设备。
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
#port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
#skip-external-locking
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
修改完成重启服务即可。
sudo service mysql restart