This is my setup (the IP numbers are fictional of course):
Server A (10.0.0.1)
hosts a database called
$connection = mysqli_connect("10.0.0.1","db_user","db_pass","database1",3306);
Access denied for user 'db_user'@'184.108.40.206' (using password: YES) in <path-to-php-file> in line 42
mysql> SHOW GRANTS FOR 'db_user';
GRANT USAGE ON *.* TO 'db_user'@'%' IDENTIFIED BY PASSWORD '<password hash>'
GRANT ALL PRIVILEGES ON `database1`.* TO 'db_user1'@'%'
mysql --host=10.0.0.1 -udb_user -p
SHOW GRANTS FOR current_user;
If you can't connect using
mysqli, try using
PDO instead. I'm not sure why, but apparently in this case PDO works.
Personally, I like PDO better than mysqli, because of named parameters instead of
?, and the ability to provide an array of values when calling
PDOStatement::execute(). You may find you like it as well.