Oct 25
Having just recently decided to start supporting MySQL, I went ahead and setup a new database server and installed MySQL 4.1.13, all seemed to be fine until I actually came to connect ColdFusion to a MySQL database, then Oops.
I got an error something like this
Connection verification failed for data source: mysql_bad
java.sql.SQLException: Communication failure during handshake.Is there a
server
running on localhost:3306?The root cause was that:
java.sql.SQLException:
Communication failure during handshake. Is there a
server running on
localhost:3306?
After a fair bit of investigation I discovered that MySQL4.x has changed the way passwords are encrypted. So anything that is using the old method will not connect to your database. This includes the MySQL drivers that come with CFMX as they are 3.x drivers.
You now have two options.
- Set your MySQL server to use the old 3.x style passwords.
- Install a newer MySQL JDBC driver.
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Use old password encryption method
old_passwords
Steps to install a new MySQL 4.x JDBC driver
- Download the MySQL Connector J JDBC driver
- Make the JDBC driver available to CFMX through the classpath by saving mysql-connector-java-3.0-bin.jar in either $CFMX_HOME/runtime/servers/lib/ for CFMX Server Configuration or $JRUN_HOME/servers/lib/ for CFMX on JRun Configuration. This makes the driver available to all JRun server instances.
- Restart CFMX server.
- Add new datasource selecting "other" as the driver
- Add the JDBC URL jdbc:mysql://[server]:[port]/[database]
- Add the Driver Class com.mysql.jdbc.Driver
- Fill in the username/password, and adjust other dsn settings if needed.
- Submit datasource for verification
- As long as the DSN verifies, don't forget to remove the username and password, as you should be passing these in your code.
Recent Comments