Centreon error

Solved
tom200 -  
mamiemando Posted messages 33541 Registration date   Status Modérateur Last intervention   -
Hello,

I’m new to computing and I’m experimenting a bit with monitoring, particularly in the Centreon environment. I’ve been struggling for a few days with this error:
SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

I want to point out that I am still in the installation phase and that I haven’t created a database yet.

Thank you in advance for the various help you will provide me.

3 réponses

mamiemando Posted messages 33541 Registration date   Status Modérateur Last intervention   7 935
 
Hello,

Preliminaries

This error means that you are trying to connect locally to your SQL server using the login
root
.

In SQL (whether it's mysql or postgresql), profiles are defined by the (user, host) pair. In mysql~MariaDB, they are more specifically defined in the mysql database, in the user table (which is written as
mysql.user
).

The user
root@localhost
(or
root@127.0.0.1
) is reserved for the server administrator to connect to the SQL server. This profile is not meant to be used by anyone else.

Some reminders (mysql)

To connect to a data server, it obviously needs to be installed and running.

Example: On Debian and distributions that are derived from it (Ubuntu, mint) to install MariaDB

sudo apt update sudo apt install default-mysql-server


You can then check that it is installed with:

dpkg -l | egrep -i "maria|mysql"


Example: To check that MariaDB is running:

(mando@antarctic) (~) $ systemctl status mysql.service 
● mariadb.service - MariaDB 10.5.8 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-01-29 22:14:16 UTC; 4 months 20 days ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/systemd/
Main PID: 1290395 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 15 (limit: 9396)
Memory: 1.3G
CGroup: /system.slice/mariadb.service
└─1290395 /usr/sbin/mariadbd


Example: in this example, I am connecting as
root@127.0.0.1
(in the next command, the parameter
-h 127.0.0.1
is implied)

(mando@machine) (~) $ mysql -u root -p

MariaDB [mysql]> select user, host from mysql.user;
+------------------+-----------+
| User | Host |
+------------------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | machine |
| mariadb.sys | localhost |
| root | localhost |
+------------------+-----------+


Back to your problem

In your case, it's a bit surprising that Centreon is trying to connect as root to your SQL server. Normally, each application has its own database and a dedicated SQL profile to connect to it (configured so as not to alter the other databases hosted on the SQL server). By definition,
root
has all the rights, and this goes against that rule.

Start by checking that the SQL server is installed and running. Make sure that the centreon database has been initialized. I imagine that centreon comes with a script that will create the appropriate SQL user, the centreon database and the tables it contains (schema). Specifically check the contents of
mysql.user
(assuming it is a mysql-type database server).

Finally, try to connect with the SQL profile defined for centreon from your terminal. If it works, everything is fine with the database. Provided that Centreon uses the same profile, initiate the connection from the same machine, and use the correct password, the connection should then establish.

Good luck!
0