drupal-vm icon indicating copy to clipboard operation
drupal-vm copied to clipboard

Access denied for user 'root'@'localhost'

Open netlooker opened this issue 10 years ago • 14 comments

After build and provisioning machine I've noticed small issue regarding connection with mysql database for root user. I wasn't able to login via default root/root either from command line or adminer. After short investigation I found that root@localhost user is using “plugin: auth_socket”. I've changed that via following commands:

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';

After this small task I'm able to login as an root. Below I'm enclosing article which is putting more light on that topic. https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/

netlooker avatar May 19 '16 09:05 netlooker

Interesting... I'll take a look—this might need to be filed upstream in the geerlingguy.mysql role repository.

geerlingguy avatar May 19 '16 16:05 geerlingguy

Confirmed the issue and suggested temporary resolution. Thanks @netlooker!

hawkeyetwolf avatar May 28 '16 17:05 hawkeyetwolf

Yep I have the same problem. Thanks for the solution netlooker

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

antonyanimator avatar Jun 01 '16 09:06 antonyanimator

I have the same issue and also can confirm that previous comment fix the problem

aleksey-tk avatar Jun 03 '16 15:06 aleksey-tk

:+1: for the solution provided by @antonyanimator and @netlooker. Got me fixed up. Thank you.

tsmith512 avatar Jun 03 '16 21:06 tsmith512

I had the same issue with the D8, PHP 7 machine. Thank you anonyanimator for the solution and netlooker for the post. Finally got me fixed up too.

mixplex avatar Jun 04 '16 14:06 mixplex

I still have issues with D8 installs, getting caught denying access to root in mysql.

mixplex avatar Jun 09 '16 02:06 mixplex

@mixplex , If you're having trouble with D8 installs during provisioning, I wonder if that's because the fix from this ticket has to be executed manually. Looks like the MySQL setup is actually pulled in from another repo, but maybe adding a command that would sudo mysql -e 'the command from above' in this file: https://github.com/geerlingguy/drupal-vm/blob/master/provisioning/tasks/install-site.yml at line 10 might be a temporary fix to support auto install?

tsmith512 avatar Jun 09 '16 02:06 tsmith512

Note that if you use a mysql_users user specific to your drupal site/mysql_databases database, then automatic installation should work without worrying about the root user account.

I typically don't rely on having access to the root MySQL account (just like I don't use the root Linux account unless it's necessary), and if I need an account to access multiple databases, I'll set that in the user's access permissions.

I still want to fix this upstream, of course :)

geerlingguy avatar Jun 09 '16 03:06 geerlingguy

Related:

  • https://github.com/ansible/ansible-modules-core/issues/3003
  • http://dev.mysql.com/doc/refman/5.7/en/default-privileges.html

geerlingguy avatar Jun 13 '16 03:06 geerlingguy

How do i fix this on windows?

jestinijames avatar Jun 13 '17 10:06 jestinijames

@jestinijames - This error can be caused by a large number of different things. It could be something with Drupal VM, or Drush, or the particular Drupal codebase you're working on, or something inside settings.php, or even tools like BLT.

It would be best if you open a new issue with every detail you can provide (along with detailed console logs) so we can help you more.

geerlingguy avatar Jun 13 '17 21:06 geerlingguy

I had the following error:

Unhandled rejection SequelizeConnectionError: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Which was solved using the above command:


sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';

But after having solved that error i was unable to log in to my mysql-database through adminer which i had been able to do before the above command. After having checked the database it seems all my tables are being added so it should be some sort of problem with adminer caused by this solution. Does anyone know how to fix it?

sirzorre avatar Aug 26 '18 22:08 sirzorre

Just to make sure, you're using the new password ("test") to log in, right?

hawkeyetwolf avatar Aug 28 '18 16:08 hawkeyetwolf