OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Database connection failed!

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Database connection failed!

Postby MichaelJ » Mon Jul 31, 2006 5:50 pm

I am having difficulty understanding how OSJ2 connects to a mysql database. So far trying to install I get Database connection failed! How do I refer to the database in the config.inc.php file?

My usual understanding of PHP / mysql would be a line of code like:
//mssql_connect and mssql_query
mysql_connect("localhost","username", "password");
// select the database
//mysql_select_db("dbname");
mysql_select_db("mydbname");
//create a variable called $myquery to hold my SQL statement

MichaelJ
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm

Postby asmecher » Mon Jul 31, 2006 7:23 pm

Hi Michael,

You just need to specify the correct database connection parameters on the installation page, and the configuration file will be written automatically using those values. In particular, make sure you choose the right Database Driver and enter the correct values for Host, Username, Password, and Database Name.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 7726
Joined: Wed Aug 10, 2005 12:56 pm

Database connection failed

Postby MichaelJ » Mon Jul 31, 2006 7:55 pm

The config.inc.php file on the Database now says:

[database]

driver = mysql
host = localhost
username = ojs
password = ojs
name = ojs

Is that good enough to make the connection? My server does run the required version of mysql. Somehow, this code to me looks inadequate. As well, I have installed the files in a folder called OSJ2 in the public_html directory. Not sure that was correct either.

Thanks for your quick reply. You must be quite fluent in PHP!

Mike
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm

Postby asmecher » Tue Aug 01, 2006 9:33 am

Hi MichaelJ,

You need to create a database and grant access credentials to it, and then use those values to create the configuration file. For example, run the following in MySQL:
Code: Select all
CREATE DATABASE my_database;
GRANT ALL ON my_database.* TO my_user@localhost IDENTIFIED BY my_password;
Then you can use the username "my_user" and the password "my_password" to access the database called "my_database".

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 7726
Joined: Wed Aug 10, 2005 12:56 pm

Database Connect failure

Postby MichaelJ » Tue Aug 01, 2006 9:36 am

Can I use PHPmyAdmin to create the mySQL database? Do I just leave all the fields blank?
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm

Postby asmecher » Tue Aug 01, 2006 9:43 am

Hi MichaelJ,

This depends on how your host has set up PHPMyAdmin; you might be able to create a database using it. In any case, OJS requires a database and you won't be able to proceed with installation until you can provide OJS with the connection information it needs.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 7726
Joined: Wed Aug 10, 2005 12:56 pm

Postby MichaelJ » Tue Aug 01, 2006 2:43 pm

asmecher wrote:Hi MichaelJ,

This depends on how your host has set up PHPMyAdmin; you might be able to create a database using it. In any case, OJS requires a database and you won't be able to proceed with installation until you can provide OJS with the connection information it needs.

Regards,
Alec Smecher
Open Journal Systems Team


The error I get now is:

DB Error: Table 'my_databasename.sessions' doesn't exist

At least it is getting closer, right? Do I have to setup tables and have a key index field?

Thanks a lot for help. Much appreciated

Mike
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm

Postby asmecher » Tue Aug 01, 2006 3:04 pm

Hi Michael,

Have you followed the install instructions? See docs/README. I suspect you're trying to use OJS without having gone through the installation procedure; the database tables haven't been created yet, which is part of the installation process.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 7726
Joined: Wed Aug 10, 2005 12:56 pm

Database connection failed!

Postby MichaelJ » Tue Aug 01, 2006 7:55 pm

My server manager said I have:

PHP 4.3.10
MySQL 4.0.27
Apache 1.3.33
OS: Linux

So I think this all compatible with the OSJ2 version I am using. I have read the README file several times and still don't know what I am missing.

I installed the files in the public_html directory on the server in a folder called OSJ2.

I made one change after re-reading the README file, changing the suggested folders and files to be writeable instead of READ only. Not sure that did anything though.

Mike
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm

Postby asmecher » Tue Aug 01, 2006 10:44 pm

Hi Michael,

I suspect you've unpacked OJS and edited the configuration file to fill in the database connection parameters etc. This is missing most of the installation process. Rather than editing the configuration file, just point your web browser to OJS's index.php and follow the instructions on the screen. You may need to restore the configuration file (config.inc.php) back to the version that was shipped with OJS.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 7726
Joined: Wed Aug 10, 2005 12:56 pm

Database connection failed!

Postby MichaelJ » Wed Aug 02, 2006 3:31 am

Hi,

I restored the original config.inc.php and uploaded it to the OSJ2 directory and got these error messages. When I change "Installed=OFF" to "On" I get the Database connectin failed message.

Warning: unlink(/home/mywebsite/public_html/ojs2/cache/fc-locale-list.php): Permission denied in /home/mywebsite/public_html/ojs2/classes/cache/FileCache.inc.php on line 52

Warning: unlink(/home/mywebsite/public_html/ojs2/cache/fc-locale-list.php): Permission denied in /home/mywebsite/public_html/ojs2/classes/cache/FileCache.inc.php on line 52

Warning: Cannot modify header information - headers already sent by (output started at /home/mywebsite/public_html/ojs2/classes/cache/FileCache.inc.php:52) in /home/mywebsite/public_html/ojs2/classes/template/TemplateManager.inc.php on line 179

Fatal error: Smarty error: unable to write to $compile_dir '/home/mywebsite/public_html/ojs2/cache/t_compile'. Be sure $compile_dir is writable by the web server user. in /home/mywebsite/public_html/ojs2/lib/smarty/Smarty.class.php on line 1095

How do I make files and folders "writeable" using Microsoft?

Mike
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm

Postby MichaelJ » Wed Aug 02, 2006 3:59 am

asmecher wrote:Hi Michael,

I suspect you've unpacked OJS and edited the configuration file to fill in the database connection parameters etc. This is missing most of the installation process. Rather than editing the configuration file, just point your web browser to OJS's index.php and follow the instructions on the screen. You may need to restore the configuration file (config.inc.php) back to the version that was shipped with OJS.

Regards,
Alec Smecher
Open Journal Systems Team


Hi Alec

On second try it has worked! I changed permissions a little on the folders necessary and reinstalled config.php.inc

Best!

Mike
MichaelJ
 
Posts: 8
Joined: Mon Jul 31, 2006 5:46 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 4 guests