Solved - The provided database host, username, and/or password is invalid, and a connection to the database could not be established

As with many posts in the forum, I also had this error while trying to install SuiteCRM. This is how I solved it.

The base LAMP install in Debian 9 and Debian 8 does a few things differently when setting defaults. So when I last did a clean installed on Debian 7, it went without issue. The following are probably necessary on Ubuntu too. (Maybe other Linuxes?)

Things to check and fix:

  1. Make sure the port 3306 tcp is open in the firewall. It wasn’t open by default after the MariaDB or MySQL install.

  2. Check you can access MySQL/MariaDB on the localhost. If you can login you should get something like this:

mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 101
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
  1. It is likely that MySQL isn’t listening on the network. So check

It looks like the post cut off the other 3 things to check so I’ll add them here.
3) It is likely that MySQL isn’t listening on the network. So check Configure MariaDB for remote client access
I added following to /etc/mysql/my.cnf


[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

# Instead of skip-networking the default is now to listen only on
# # localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0

In my case I set up Apache to have the SuiteCRM install in /var/www/suitecrm. So there were localhost at 127.0.0.1 and suitecrm.domain.tld at 127.0.1.1. With bind-address 0.0.0.0 all local network connections should be able to connect to the db.

Step 4)
Debian and Ubuntu (maybe other Linuxes) changed the default authorization on mysql installs. So you have to change this. See mysql authorization change.

MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------+---------------+-------------+
| User | Host          | plugin      |
+------+---------------+-------------+
| root | localhost     | unix_socket |
+------+---------------+-------------+

But should be

MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------+---------------+-----------------------+
| User | Host          | plugin                |
+------+---------------+-----------------------+
| root | localhost     | mysql_native_password |
+------+---------------+-----------------------+

Step 5) In the install script for SuiteCRM it will pull the IP address of the server to put in the database location. This didn’t work for me. I had to enter ‘localhost’ in the dialog box instead.

2 Likes

Hi!

This is not necessary in Ubuntu, installation is pretty straightforward there.

Anyway, in what regards Debian, thanks for sharing your notes here, if everybody did that after solving their particular installation problems we’d have a great “database” of installation troubleshooting instructions by now. I’m sure this will help someone in the future.

@nuke, I have struggled with this for half a day now and decided to search the web.

I recalled this from a vtiger setup years ago, This fixed my issue
Cheers Bernard

1 Like