Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rainieren's avatar

Laravel valet MySQL - PHP Artisan migrate stuck, no response

Recently I installed Laravel valet on my Mac. I want to use MySQL and went to the section "database" in the Laravel Valet documentation. There it says the following:

If you need a database, try MySQL by running brew install [email protected] on your command line. Once MySQL has been installed, you may start it using the brew services start [email protected] command. You can then connect to the database at 127.0.0.1 using the root username and an empty string for the password.

I followed the exact steps and made a connection via the build-in database tool in PHPStorm, which went fine. I looked at my .env file and it contains the right data

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=rainierlaan
DB_USERNAME=root
DB_PASSWORD=

I made a database called rainierlaan and ran php artisan migrate. But I get nothing in return and the command seems to be stuck.

What I have tried

  • Reinstalled MySQL by doing brew uninstall [email protected] and brew install [email protected]
  • Installed another MySQL version (8.0) which it is running on now.
  • Ran php artisan migrate -v. Same response, looks like the command is stuck.
  • Ran php artisan config:clear but has no effect
  • Ran composer dump-autoload but also seems to have no effect.
  • Checked with mysql -u root to see if the table rainierlaan exists, and it does.

How can this be solved?

0 likes
15 replies
Nakov's avatar

@rainieren Have you tried using localhost for DB_HOST instead?

Also check if mysql is running on the default port. You can do that using mysql -uroot then when within mysql run this command:

SHOW GLOBAL VARIABLES LIKE 'PORT';

it should be 3306.

So if you leave it like that it is just stuck forever, or does it exits after a while?

Rainieren's avatar

Hey @Nakov, It shows the right port. The command is just stuck forever, I left it on for more than 2 hours and nothing. I tried changing it to localhost but no luck.

Rainieren's avatar

@nakov I removed mysql by doing brew services stop mysql, brew unlink mysql and brew uninstall mysql and downloaded the .dmg file from Oracles website. Now whenever I want to do mysql -u root it says ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) and I can't connect anymore via the build-in database tool in PHPStorm while using the right password. which is rootroot. I updated my .env file and tried it all again but with no luck

Edit:: php artisan migrate now gives this:

Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = rainierlaan and table_name = migrations and table_type = 'BASE TABLE')
Rainieren's avatar

@nakov sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking & does nothing

Nakov's avatar

@rainieren you are following the post completely right? Because that command should start the mysql server without a need for a password..

Please read the whole article.

Rainieren's avatar

I did read the whole article and tried the steps but It does not the start mysql server. The commandline outputs this:

rainierlaan@MacBook-Pro-van-Rainier rainierlaan % sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
[2] 61723
rainierlaan@MacBook-Pro-van-Rainier rainierlaan % sudo: /usr/sbin/mysqld: command not found

[2]    exit 1     sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
rainierlaan@MacBook-Pro-van-Rainier rainierlaan % 
Nakov's avatar

You stopped the service first, and then you tried that one? I am trying it myself as well, it works as it should.

Rainieren's avatar

I did not stop any service? I just ran the command as it says on the website and that is my result.

Rainieren's avatar

I followed the exact steps and again with no luck. I turned off MySQL server and ran the command and proceeded to connect to my database but can't

rainierlaan@MacBook-Pro-van-Rainier rainierlaan % sudo mysqld_safe --skip-grand-tables                                 
Logging to '/usr/local/mysql/data/MacBook-Pro-van-Rainier.local.err'.
2019-12-28T15:31:35.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2019-12-28T15:31:37.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/MacBook-Pro-van-Rainier.local.pid ended
rainierlaan@MacBook-Pro-van-Rainier rainierlaan % mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
rainierlaan@MacBook-Pro-van-Rainier rainierlaan % mysql -u root root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
rainierlaan@MacBook-Pro-van-Rainier rainierlaan % 
Nakov's avatar
Nakov
Best Answer
Level 73

@rainieren Are you sure you've setup a password when you installed it, because by default it has just a root user and no password.

If you did, then try reinstalling again, don't know what else to tell you. Btw, for each step that you have shown me I googled the error, so many responses. So use that as well.

Please or to participate in this conversation.