-1

Trying to access MYSQLfrom remote server. i have 3 db(db1,db2,db3).

db2 & db3 are in same server, db1 is in my old server.

Trying to connect db1 from new server using mysql_connect('ip','user','pwd'), But it shows Access denied for user 'user'@'ip-address' message.

Both db1,db2 are connecting the same way.

What is the solution for this? I tried some privilege allocation, but doesn't work.

Shijo Rose
  • 193
  • 5
  • 17

3 Answers3

0

First give rights on db1 to your user, you can use below command-

grant select, insert, update, delete on db1.* to myuser@'my_server_ip' identified by 'my_pass';

Note: You can add/delete privileges as per your requirement here my_server_ip means from where you are trying to connect db.

Second thing, as you are trying to connect db1 remotely so also include host ip in your connection string.

Zafar Malik
  • 6,734
  • 2
  • 19
  • 30
0

You have to enable the "Remote Access".

To do it, follow the following steps:

  1. locate your my.cnf file and open it:

vi /etc/my.cnf

  1. after [mysqld] just remove or comment skip-networking command.

  2. add the following command:

bind-address=YOUR-SERVER-IP

Ahmad
  • 808
  • 9
  • 14
0

This problem is solved by giving privileges to user@host.

GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP-ADDRESS' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

NOTE:Do not avoid "PASSWORD", if your user has set password

Shijo Rose
  • 193
  • 5
  • 17