PDA

View Full Version : connecting to mysql db from an outisde php script


k007
03-27-2008, 07:14 AM
hello,

i have been trying to connect to the vb db of my forums just to read _session but i cannot seem to connect, i have tried connecting from another host with the same username/pass from the vb config file, i get errors about this host has no access to connect to this db.

i have also tried connecting from the local host but i kept getting the same error which is
Access denied for user 'username'@'host' (using password: YES)
and i have also tried creating a totally new mysql user and gave it access to the vb db and tried to connect from there but i still get the same exact error.

yeah im sure im using the right info and the users got the right access.

i have tried connecting to the db using the normal mysql_connect, pdo and using a custom framework tool(code igniter) but everyone gives me the same error.

thanks,

Dismounted
03-27-2008, 09:17 AM
Connect from localhost with the username/password combination from your config file.

Opserty
03-27-2008, 10:23 AM
Are you trying to connect from one server to a MySQL database on another account/server?

Or are your scripts located on the same server/account as the MySQL database?

k007
03-27-2008, 05:40 PM
i tried both, connectin as a localhost and from an outside script but same problem. yeah i have pulled off the info from my config file.

Dismounted
03-28-2008, 02:39 AM
Then does your vBulletin work? If it doesn't, you have issues with the combination, if it does, you're doing something wrong in your script. Also, MySQL will (by default) limit connections to only the localhost, this is a security feature.

k007
03-30-2008, 07:52 AM
yeah the forums works ofcourse lol, i have fixed issue by just changing the hostname from the ip/name.com to 'localhost', and for the external web server i just went to cpanel and added the web server ip as mysql host and worked too.