bee
bee copied to clipboard
Bee unable to connect to database (but site works fine in browser)
Recent versions of mysql/mariadb changed the way local connections work so that @localhost is no longer allowed in the connection string, and @127.0.0.1 is required instead. We updated core to try both options before refusing a connection.
Now my site works as expected, but bee now fails with the following error:
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /backdrop/core/includes/database/database.inc:325
See related core issue https://github.com/backdrop/backdrop-issues/issues/2520
Hi @jenlampton
Please can you advise which bee command you were using. The only place we give localhost as a default is in the bee install command. In the db- commands we use what is in settings.
I have a feeling this might depend on how the user is recorded when added. I've just checked in my Lando installation for bee and it shows like this:
MariaDB [mysql]> SELECT Host, User FROM user
-> ;
+------+----------+
| Host | User |
+------+----------+
| % | backdrop |
| % | root |
+------+----------+
2 rows in set (0.004 sec)
so in that case I figure it's not going to matter.
I'm wondering whether it will be sufficient to change the default in bee install to use 127.0.0.1 or whether we need to consider this wherever we use backdrop settings.
Incidentally, in bee install the actual installation process is handed off to /core/scripts/install.sh - it is in db functions and status where we actually connect using the details from backdrop settings.
@jenlampton - reading again the backdrop issue, I wonder whether this is down to the way that particular hosts configure their webserver and database server. On my host, (in contrast to lando), it shows using SHOW GRANTS; (I don't have permissions for the mysql.user table there) it shows that the username is recorded as localhost.
What does SHOW GRANTS look like for your backdrop user (with sanitized username)?
I'm happy to try and do something but I don't know what is needed here.
Looking at the backdrop code, it looks to re-write the settings if it fails during the install but does it do anything if things change after installation?
I'm wondering whether doing a separate function using backdrop_rewrite_settings would be better than changing every function to handle the settings being wrong for the db permissions.
I don't think it's related to grants, there's nothing in there about localhost., we're using % instead.
GRANT ALL PRIVILEGES ON
username.* TOdatabasename@%
@jenlampton - any ideas what you would like me to do (if anything)?
The only place bee defines this is as a default in the install command, though it can be overridden there. The rest of the time it gets the database settings from Backdrop.