-1

I feel like I've tried everything. user root with empty password doesn't work.

Tried uninstalling and reinstalling mysql. Doesn't work.

Thinking this had something to do with my project in Laravel, I uninstalled and reinstalled it. Started a fresh project. Nope.

Uninstalled reinstalled Homestead. Nope.

Uninstalled reinstalled Vagrant. Nope.

My database config in Laravel looks like this:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

But when I try:

mysql -u homestead -p

and 'secret' I get:

ERROR 1045 (28000): Access denied for user 'homestead'@'localhost' (using password: YES)

I followed all the steps to this post, and....can you guess? NOPE NOTHING.

Access denied for user 'homestead'@'localhost' (using password: YES) on Laravel 5.2.27

Please help. I will be happy to provide any more information if I missed anything.

Hana
  • 85
  • 1
  • 9

3 Answers3

1

I had an old version of Homestead.yaml laying around I think. All I had to do was to change mysql to true under features in my Homestead.yaml. This was false for some reason.

Then i did vagrant destroy vagrant up And everything was working. Hopefully this helps someone

tzin
  • 11
  • 1
  • This has been the problem on more than one occasion for me. I always assume Homestead is MySQL enabled by default. – BadHorsie Jan 15 '22 at 23:22
0

I've ran into this before and honestly sometimes it differs from one person to another, so here is a couple of solutions I know:

First:

  • Add a password to mysql by running mysqladmin -u root -p pass

But I believe you already tried that so on to the next one,

Second

  • use this query inside the mysql cli:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');

Please notice that this method directly manipulates your database, you just have to start your mysql cli inside your vagrant vm, and type that query as it is inside, then try to login with root as the username and root as password, hopefully this helps.

Omar Tarek
  • 734
  • 1
  • 7
  • 19
-1

You can try reseting the root password by running MySQL in Safe Mode.

  1. Stop MySQL:

    sudo /usr/local/mysql/support-files/mysql.server stop

  2. Start it in safe mode:

    sudo mysqld_safe --skip-grant-tables

This will be an ongoing command until the process is finished so open another shell/terminal window, and..

  1. Log in without a password as root:

    mysql -u root

  2. Update root (and any other user's) password)

    FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; \q

  3. Restart MySQL in normal mode

    sudo /usr/local/mysql/support-files/mysql.server start

Reference: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/

Note: this is pretty much a copy-paste from the reference link. this is pretty standard reset procedure, but just documented better in that guide compared to mysql reference docs.

CVG
  • 137
  • 7