PDA

View Full Version : mysql_connect


owenb
11-14-2009, 12:48 AM
Hi. I am just starting to look at Quercus using Resin 3.1.9

With a simple php app that uses the old school mysql_connect($h,$u,$p) form, I get the following exception:

java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO) [mysql_error] Couldn't connect to the MySQL server at 10.0.4.204

It does seem to be passing the host (which is the ip address in question) correctly, but it is not passing the username and password. Is that supported? The documentation indicates that it is, but most of the examples use PDO.

Thanks!

nam
11-14-2009, 01:04 AM
mysql_connect() works for me with "root" and my password, connecting to an external ip (xx.xx.xxx.xxx).

What format are you passing in the host as? And are you using a JDBC database (that's defined in your resin.conf)?

Also, keep in mind that mysql by default does not allow root connections from external networks.

owenb
11-14-2009, 05:24 PM
Okay, I will try to re-test. The mysql_connect() params were "ip_address", "user", "password". It's a normal connect string from an existing application. So, it's not root, it's a specific user/password, and it's from a server which can connect to mysql normally. It does use an ip address, not a host name to connect. I created a jdbc connection in the config file and I was able to connect using PDO, but the mysql_connect still fails because it's trying to connect to localhost / blank username /no password.

I will try to take a look at the source code to see what might be wrong, but at least now I know it _should_ work, so that's more than I knew before.

Thanks!

owenb
11-14-2009, 10:12 PM
mysql_connect works with resin-4.0.1 with the same parameters. Still not sure what the root problem was though.

One weird difference with 4 is that I can't find the .java or .class files. They don't seem to be going into /tmp/caucho as suggested by the manual. Is that a config option? Is it just caching them all in memory?

nam
11-16-2009, 05:36 PM
the classes should be compiled to resin/webapps/ROOT/WEB-INF/work