Database connection failed! OJS 2.4

We are running OJS 2.4, on Ubuntu, with MySQL 5.7.17 for an international academic journal.

Suddendly, the system gave this message:

Database connection failed!
Stack Trace:
File: /var/www/html/journal/classes/core/ line 38
Function: PKPApplication->PKPApplication()

File: /var/www/html/journal/lib/pkp/includes/ line 59
Function: Application->Application()

File: /var/www/html/journal/index.php line 70
Function: require("/var/www/html/journal/lib/pkp/includes/")

It seems related to the login to the database connection. However, the error is very strange. We restored some back-up copies, which had worked well for some days and we have seen that either they don’t work at all (always the same error, as above) or they work for some time, but after some OJS admin/user logins/logouts the system crashes (BTW, they should not be relevant, as the mysql login should happen only once at the beginning of the session, but I don’t know. Also, from one test it seems that the crash happens also not while doing a user login/logout).
Nothing else changed: the back-up was of the whole machine. We also moved back the system date, no change.
The problem could be due to the change of the secure_auth global variable in MySQL, that now is only ON, but the OJS system had always worked well.

We’ll try to do the upgrade to OJS 3, but we would like to solve the problem before

Hi @Francesco,

That message simply suggests that OJS isn’t able to connect to MySQL using the credentials in I’m not sure how to explain the seemingly intermittent nature you describe; this is the kind of thing that should simply work, or not work. Is it possible that someone or something is changing your MySQL password e.g. with a GRANT SQL statement?

If your has persistent turned on, try setting it to Off; this may make debugging a little simpler, and should perform fine with MySQL anyway.

Alec Smecher
Public Knowledge Project Team

Thank you Alec!

we reverted to a much older back-up of the machine, and imported tha latest data on the database.
the system is now correctly up. The problem was probably due to an incopatible update in the OS or MySql.
In any case, we’ll proceed with an OJS upgrade asap…

Best regards,

We successfully upgraded to the latest version (OJS 3.0.2), and left the Ubuntu automatic upgrades. After some hours working, we got the same error as we had on OJS 2.4.
This is probably due to the automatica upgrade of mySql from 5.5 to 5.7, where secure_auth is mandatory, so the OJS passwords do not fit anymore.
Actually, the problem is with the latest version of MySQL (5.7.17).

Database connection failed!

Stack Trace:

File: /var/www/html/journal/classes/core/ line 38
Function: PKPApplication->__construct()

File: /var/www/html/journal/lib/pkp/includes/ line 58
Function: Application->__construct()

File: /var/www/html/journal/index.php line 65
Function: require("/var/www/html/journal/lib/pkp/includes/")

Hi @Francesco,

It sounds to me like something is happening on your server that’s out of OJS’s control.

I would suggest using a simple PHP script to check your database credentials. See for an example. If you can get that script working, but OJS still refuses to connect, then I can help debug it here; otherwise, it’s something outside of OJS, and something like Stackoverflow might be a better resource.

Alec Smecher
Public Knowledge Project Team

The script does not work. The error is: error: Unable to connect to MySQL. Debugging errno: 1698 Debugging error: Access denied for user ‘root’@‘localhost’
However, if I connect through the mysql command line, with the same password, the mysql access is given.
So, the problem is outside OJS…

It seems that the problem can be solved by associating the framework to a new user created with the new version of MySQL

it’s happened to me too,
i just chage my database password to combination of alfanumeric character (i use numerik password before)
and it’s work to me…

1 Like

Hi @Francesco, @warsono and @asmecher,

The same thing is happening to me in version, and I would like to know how they solved this problem, or how they modified the OJS database user or their password.