php - MySQL - Access denied when connecting locally but able to connect remotely -
i've got php application hosted both on server , locally xamp, , i've got db hosted in same server, too.
when trying found connection db instance new mysqli object this:
$mysqli = new mysqli(host, user, pass, my_db); the value constants same local , remote applications reason work when used on xamp; 'access denied user' when trying connect server , have no thought problem might be.
sorry bad english, , help :)
there's 2 options: either binding remote ip , not local 1 or messed permissions.
1. binding ip adress
if followed online tutorial on how allow remote access, set config alternative bind-adress axternal ip. means, server bind externally not on internal loopback (127.0.0.1/localhost).
all have is:
open config file (usually/etc/mysql/my.cnf) root permissions locate setting bind-adress , set 0.0.0.0 2. permissions
try granting permission through terminal '<your user>'@'%'. if don't understand means, read grant manual here.
here's illustration giving superuser permissions user anywhere every database:
grant privileges on *.* '<your user>'@'%' grant option; i wouldn't recommend using above on production server since big security risk.
php mysql mysqli
No comments:
Post a Comment