gpt4 book ai didi

php - 如何连接远程mysql数据库

转载 作者:太空宇宙 更新时间:2023-11-04 04:18:10 25 4
gpt4 key购买 nike

我已经查看了所有相关的问题和答案,但仍然无法连接到远程 mysql 数据库。

到目前为止我所做的是..

1

CREATE USER 'root'@'192.168.1.100' IDENTIFIED BY  '***';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'192.168.1.100' IDENTIFIED BY '***' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

2

my.cnf file in server (which is in /etc/my.cnf path let me if it is not correct)
[mysqld]
innodb_file_per_table=1
#bind-address = 127.0.0.1
#skip-networking

以下是我的项目的database.yml。

all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: mysql:host=[ip of remote server];dbname=dev_db
username: user
password: user12
encoding: utf8
attributes:
use_native_enum: true
default_table_type: INNODB
default_table_collate: utf8_unicode_ci
default_table_charset: utf8

我遇到以下异常

PDO Connection Error: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '50.115.116.203' (4)

那么配置远程数据库还缺少什么。

请帮忙

谢谢。

最佳答案

192.168.1.100 这是本地网络 IP,您已将此 IP 用作您的用户允许的主机。但是,当您连接到此服务器时,您将使用公共(public) IP 地址50.115.116.203。请检查您连接的服务器是否与您为用户添加的允许主机具有相同的 IP

关于php - 如何连接远程mysql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15118536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com