首页 > 解决方案 > 默认连接远程数据库

问题描述

您好,我正在尝试默认连接到我在 cpanel 上的远程 mysql DB

我已经允许访问我试图用来连接到 cpanel 中的远程数据库的 IP

我试着改变/etc/mysql/mysql.conf.d/mysqld.conf

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/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            = 189.251.13.63
#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#

保存更改后,我去了/etc/init.d/然后做了mysqld restart

尝试使用sudo mysql它并继续访问我的本地主机数据库,我做错了什么?

标签: mysqllinux

解决方案


您可以$HOME/.my.cnf使用以下输入创建:

[client] 
user=... 
host=...
port=...

mysql当您在命令行上没有提供其他选项时,客户端应该从此配置文件中获取默认连接参数。


推荐阅读