mysql - 默认连接远程数据库
问题描述
您好,我正在尝试默认连接到我在 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
它并继续访问我的本地主机数据库,我做错了什么?
解决方案
您可以$HOME/.my.cnf
使用以下输入创建:
[client]
user=...
host=...
port=...
mysql
当您在命令行上没有提供其他选项时,客户端应该从此配置文件中获取默认连接参数。
推荐阅读
- docker - asp.net core docker-compose 刷新代码更改
- c - 我需要帮助弄清楚为什么这不起作用。(C)
- tizen - 在哪里可以找到 Tizen 操作系统统计信息
- vba - 在 msforms.textbox 中实现鼠标滚轮
- three.js - 让一个物体追逐另一个物体
- python - python - 如何将列表中的每个项目附加到Python列表中的列表中?
- c++ - 是什么污染了这里的全局命名空间?
- reactjs - 尝试使用 openlayers、Golden Layout、reactjs。但是 openlayers 地图仅显示在黄金布局的 1 个窗口中,而不显示在其他窗口中
- mongodb - MongoDB,如何选择合适的设计?
- azure - 如何将具有多个资源的 Terraform 模块导入其他状态 - Azure