Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Migration stalls and doesn't do anything

Just went through all the steps listed on the Laravel site to install and get up and running for MacOS HighSierra. I currently have Composer, Homebrew, valet, PHP 7.2.8, MySQL version 8.0.11 and Laravel 5.6.28 installed. I can create a new project by doing the Laravel new blog command and not have any problems. Also when I go to my browser I can see current project I just created or am working on. I can run the valet list command and so I know its running/working. I also can create a migration and have it show up in my project as well by running the php artisan make:migration test_test_test.

My PATH also has ~/.composer/vendor/bin in it as well.

my .env file look like such

APP_NAME=Laravel
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

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

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1 
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp 
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

I run the php artisan migrate -vvv command and it runs and stalls/hangs up with no output. I have to ctl-c to get out of it. tried the -v /-vv as well, did the same thing.

I created a database named blog and even add a table test manually to make sure that the database was working/running.

Update

Went ahead and uninstall MySQL and reinstall it. I was able to get the php artisan migrate -v command to run and am getting this error.

now I'm getting this error.

MacBook-Pro:anything computername$ php artisan migrate -v

PDOException  : SQLSTATE[HY000] [2006] MySQL server has gone away

at /Users/computername/Sites/anything/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
64|         if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
65|             return new PDOConnection($dsn, $username, $password, $options);
66|         }
67| 
> 68|         return new PDO($dsn, $username, $password, $options);
69|     }
70| 
71|     /**
72|      * Determine if the connection is persistent.

Exception trace:

Created a router and view that connects to a table that I creates to see if I would be able to access the database variables and print them out. On return I got this error.

Exception message: PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109

like image 454
whisk Avatar asked Jan 28 '23 17:01

whisk


1 Answers

I myself had this problem and getting the error Exception message: PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109

This is how i fixed it:

I logged into mysql as root user like so mysql –uroot –p and entered my password

You can get a list of the users that are on the server by typing this SELECT User, Host FROM mysql.user;

Make sure that you see the user you are trying to connect to the database from your .env file. You will need to altered the current user to use the caching_sha2_password that is required in the lasted version of mysql.

Here is that command.

ALTER USER `username`@`localhost` IDENTIFIED WITH caching_sha2_password BY 'password';

While still logged in as root user you need to run this command to allow for your user to do the needed tasks that are allowed for an php artisan migrate to happen. Ex: CREATE, DROP, ALTER, DELETE and such.

GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';

If this doesn’t work you can also pick and choose what commands you want to allow instead of giving them complete access.

GRANT SELECT, INSERT ON *.* TO 'someuser'@'somehost';

Hope this helps~

like image 163
poohbear Avatar answered Feb 05 '23 17:02

poohbear