Cannot connect to MySQL

Hi guys,

I have this issue also and I’m trying to track down where it has come from. It appears to be present since the mariaDB source was changed in ansible here: https://github.com/roots/trellis/commit/f7873ec29f7544b20255e05aaadd18403b98307b

It appears there is an issue with the plugin unix_socket and the vagrant user not being allowed to login as root because unix_socket requires sudo. That explains why vagrant access for the WP user still functions. But connections to the mysql root user from the vagrant user, i.e. when accessing your local DB via a GUI, is not allowed

I’m still understanding what’s exactly happening I’m no expert with mysql / mariadb.

A temporary fix is to do the following when SSH’d into your local vagrant:

// Login as sudo enter password from group_vars/development/vault.yml -> vault_mysql_root_password
sudo mysql -u root -p
// Self explanitory
use mysql;
// Remove the unix_socket plugin for the root user
UPDATE user SET plugin = '' WHERE user = 'root' ;
// Update the root password swapping vault_mysql_root_password for your password
UPDATE user SET password = PASSWORD ( 'vault_mysql_root_password' ) WHERE user = 'root';
// Flush privileges
flush privileges;

Can anyone else confirm that with the latest HEAD version of Trellis this is the case for them too? A quick check would be to, grab the latest Trellis:

// SSH into vagrant
vagrant ssh

// Test mysql access by entering root password when prompted i.e.
mysql -u root -p

The returned error no matter if the password is correct or not is:
ERROR 1698 (28000): Access denied for user 'root'@'localhost' (using password: YES)

4 Likes