Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bee unable to connect to database (but site works fine in browser) #284

Open
jenlampton opened this issue May 8, 2023 · 4 comments
Open

Comments

@jenlampton
Copy link
Member

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 backdrop/backdrop-issues#2520

@yorkshire-pudding
Copy link
Collaborator

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.

@yorkshire-pudding
Copy link
Collaborator

@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.

@jenlampton
Copy link
Member Author

jenlampton commented Sep 11, 2023

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.* TO databasename@%

@yorkshire-pudding
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants