TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Sometimes kohana does not fill in the db-password
  • I'm building a webshop. In my admin part i sometimes (not all the times) get this error:

    mysql_connect() [function.mysql-connect]: Access denied for user '<>'@'localhost' (using password: NO)

    Stack Trace

    system/libraries/drivers/Database/Mysql.php [61]: mysql_connect( localhost:, <> )

    conclusion --> kohana does not fill in the password when calls mysql_connect

    I don't have a clear situation description because it looks totally random. It only happens when updating rows in tables (UPDATE queries). Not when I run a SELECT or INSERT query.

    The strange thing is that when it occures at a certain UPDATE the error will consequentially show up (at for example a certain article) but when you update another article it does not happen. So as I said don't have a clear situation description so this is very annoying for our project and my staff (they want to be able to edit the productinformation). It looks like it only happens with some databasetables.

    The previous version of our webshop website was not using kohana and had no problems with updates (they are on the same host).

    In my test environment I never get this error. But at my test-environment the database has no password. So why it says "using password: NO"? I am using a password and have it configured in: system\config\database.php

    So it looks like kohana sometimes neglects this password and uses no password instead for some strange reason.

    edit: It only happens sometimes at popup edit screens (javascript: window.open(..))

    I hope someone has any ideas because I can't find anything on the internet about this. (it looks like we are the only one with this problem)

    Thanks in advance

  • Is this kohana 2 or 3?
    How many connections do you have listed in your database config file? Are all the models using the same database connection instance?

    EDIT: did you replace the db username yourself or is that actually how it was presented?
  • RoelRoel, can you try commenting out line 226 in the Database.php file (the line number might be a little different depending on what 2.3.x version you are using)? It's possible you are trying to reconnect to the database for some reason and it doesn't have the password anymore.
  • Try disabling persistent connections, this typically causes all kinds of hard to identify database issues.

  • Posted By: BRmattdid you replace the db username yourself or is that actually how it was presented?

    I replaced it.

    Posted By: IsaiahRoelRoel, can you try commenting outline 226 in the Database.phpfile

    Tried it but it didn't help (also commented it out in the driver file Mysql.php)

    Posted By: shadowhandTry disabling persistent connections

    This was already disabled

    I'm using Kohana v2.3.4
  • I think I have solved it but I still don't really understand it.
    I was putting instances of objects of my model in cookies (that most of the time did not fit because of the 4kb limit) and the error only occurred at object that where < 4kb (that did fit). (session was set to cookie)

    But I still don't really understand what this had to do with the databaseconnection.
    I removed my (crappy) object to cookie code and put caching on the todo list :)

    Thanks for the replies.
  • I'm now having this same problem. I've tried changing the session to use native, and cache (originally was cookie) but I still get the error.

    Did anyone find a solution to this?
  • On my local test environment objects in the session or retrieved from cache have access to the database but on a my shared host this is not possible... Maybe this helps you.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion