简体   繁体   中英

How to connect to remote mysql database

i have viewed all the related question and answers but still having problem to connect to remote mysql database.

what i have done so far is..

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

following is the database.yml of my project.

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

I am getting following exception

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

So what else is missing to configure remote database.

Please help

Thank you.

192.168.1.100 This is a local network IP, you have used this IP as the allowed host for your user. However when you connect to this server you are doing so using Public IP Address 50.115.116.203 . Please check if the server you are connecting from has the same ip as you added for your user as allowed host

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM