Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.11.1 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

Configure database credentials for version 2.6


This is my first installation and I installed version 2.6 on Centos 7. Following the documentation for an RPM install, It installed successfully. But then following the documentation for securing the system, I was told to change the password on the database, which I did. I then also had to change the password in the /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php file, which I did so it looks like:

define("DB_NAME", "ocsweb");
define("SERVER_READ", "localhost");
define("SERVER_WRITE", "localhost");
define("COMPTE_BASE", "ocs");
define("PSWD_BASE", "newpassword");

I was also told to change it in z-ocsinventory-server.conf. That file does not exist on the filesystem, but I do have an ocsinventory-server.conf file in /etc/httpd/conf.d, and it appears to be the same file. I changed the setting in that file so that it looks like this:

PerlSetVar OCS_DB_PWD newpassword

under the # Master Database settings heading.

After restarting apache, I could not access the front end due to no database access. I went and changed the password on mariadb back to the default "ocs", and the system worked again. Deciding to leave it like that, I continued to install an agent on Windows. When the agent ran, it appeared to work, but nothing appeared in the front end. Tailing the apache error logs, I saw that it was trying to do a rollback on a non existing object. I set mariadb to log general queries, and saw that whenever the agent ran, it was getting an "access denied" error from the database. Going back to /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php, I set the password in there to the password that I originally changed to, then the agent started working.

On the web frontend, I get a security warning telling me that the password on the database is the default. Can somebody please explain to me how I should be changing that? I have noticed that changing it in either of the above mentioned files has no affect on the web front end. I set it to anything I want, and the front end still works.

Kind Regards.


in OCS Inventory NG server for Unix by (200 points)

5 Answers

0 votes

It look like you have not change correctly the password in MariaDB.

SET PASSWORD FOR 'ocs'@'localhost' = PASSWORD('newpassword');
by (22k points)
0 votes

Hi Kapouik. Thanks for the response.

I run your mysql commands as root from mysql. I test it by running "mysql -u ocs -p ocsweb" and using the new password I have access. Using the old password, I do not.

I change the password in "/usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php" to the new password as well as in /etc/httpd/conf.d/ocsinventory-server.conf and /etc/httpd/conf.d/ocsinventory-restapi.conf.

I restart mariadb as well as httpd. I even re-boot the server. When I try to access the front end, I get:

ERROR: MySql connection problem 1045
Access denied for user 'ocs'@'localhost' (using password: YES)

I set the password back in all places, and I get the login screen.

It seems as if ocsreports is not reading its username and password from the configuration files.

Kind Regards.


by (200 points)
0 votes


seem acces right problem on db ocsweb for ocs user, try to grant acces with :

grant all privileges on ocsweb.* to ocs@'%' identified by 'newpassword';
grant all privileges on ocsweb.* to ocs@localhost identified by 'newpassword';

by (5.7k points)
0 votes
Thanks toutafait. I have tried that, same result.
It seems to be something in the way mod_perl is behaving (some form of caching?). I left last night with everything working. This morning, I was getting access denied when the agents tried to connect. Restarting httpd fixed it.

by (200 points)
0 votes

Check newpasword in this two files


Edit ocs password around line 31.

Edit ocs password around line 6.

by (5.7k points)
Powered by Question2Answer