EllisLab text mark
Advanced Search
     
Can’t connect to (working) database
Posted: 09 October 2012 07:17 AM   [ Ignore ]
Joined: 2012-10-09
2 posts

Hi there,

I’m just starting with CodeIgniter and followed the tutorial to get used to it. When it came to the database connection I ran into a problem.

The application I want to develop has to deal with an existing MySQL database that’s accessible over the internet. My current development webserver runs locally. I set the correct connection parameters in the config/database.php and tried to connect to that database, which didn’t work. I get this error: “Unable to connect to your database server using the provided settings.”

So I carefully tried the very same username, password, host & db name with other clients: with command line mysql I can instantly connect flawlessly, same with gui clients like HeidiSQL. Everything works as expected. Btw: the hostname resolves correctly, I also tried the plain ip address, same behaviour.

I put back these obviously correct settings back into database.php and I get the same error mentioned before.

To make things a little more strange: I installed MySQL locally and tried to connect to that db with CodeIgniter - and it worked.

I have to access the database on the internet as all the relevant data is in there, so a workaround with a local db renders the whole project useless.

I greatly appreciate your help, thanks in advance!

Rob

 
Posted: 09 October 2012 07:53 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-10-09
2 posts

I found the problem:

The existing db seems to have been upgraded from MySQL 4.x to 5.x at some time in the past. The newer MySQL versions do use another kind of password hashing and the db still contained the old hash. You can “rehash” the password using this sql command run on the db:

SET PASSWORD PASSWORD('your_existing_password'

After that, I can connect from CodeIgniter without any problems.

Cheers,
Rob