1

I am running Vagrant & Virtual Box - I have a PHP/MySQL setup within my Vagrantfile when I vagrant ssh via the terminal I can access my database directly without any issue using the default root user (password is 'root')

My Vagrant IP is 192.168.33.1 and I have added this to my hosts file to map to dev.myworkspace.com

When I run the following command to access the mysql -h dev.myworkspace.com -u root -p & enter the correct password (root) it returns the following error:

ERROR 1045 (28000): Access denied for user 'root'@'192.168.33.1' (using password: YES)

I have tried adding bind-address = 0.0.0.0 to the my.cnf file within the vagrant box but when I restart mysql it hangs.

Can anyone explain what I am doing wrong? I just want to be able to connect to my vagrant MySQL database albeit from outside vagrant ssh (so need to allow external connections)

NOTE - the root user has been setup as the follows: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'

Zabs
  • 13,852
  • 45
  • 173
  • 297

1 Answers1

0

I looks that the permission for user root are only set to localhost

Try this to queries. If the second gives no result try the update and **flush*

SHOW GRANTS FOR  'root'@'localhost';
SHOW GRANTS FOR  'root'@'%';

UPDATE mysql.user
SET Host='%' WHERE Host='localhost' AND User='root';

FLUSH PRIVILEGES;
Bernd Buffen
  • 14,525
  • 2
  • 24
  • 39
  • Thanks for that Bernd - I am getting : | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION and | GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' | When i run the UPDATE command you added I get the following error: ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' – Zabs Feb 22 '19 at 14:15
  • @Zabs - can you please see if all passwords are the same from user **root** like **select Host,User,Password from mysql.user where user='root';** – Bernd Buffen Feb 22 '19 at 16:58