Laravel Migration停滞不前 [英] Laravel Migration stalls and doesn't do anything

查看:96
本文介绍了Laravel Migration停滞不前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需完成 Laravel网站中列出的所有步骤,即可安装并启动并在 MacOS HighSierra 上运行.我目前安装了Composer,Homebrew,valet,PHP 7.2.8,MySQL版本8.0.11和Laravel 5.6.28.我可以通过执行Laravel new blog命令来创建一个新项目,并且没有任何问题.另外,当我进入浏览器时,我可以看到我刚刚创建或正在处理的当前项目.我可以运行valet list命令,因此我知道它的运行/工作方式.我还可以通过运行php artisan make:migration test_test_test创建迁移并将其显示在我的项目中.

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.

我的PATH也有~/.composer/vendor/bin.

我的.env文件看起来像这样

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}"

我运行php artisan migrate -vvv命令,它运行并停滞/挂起,没有任何输出.我必须ctl-c才能摆脱它.也尝试了-v /-vv,做了同样的事情.

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.

我创建了一个名为blog的数据库,甚至手动添加了一个表test以确保该数据库正在运行/正在运行.

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

更新

继续并卸载MySQL并重新安装它.我能够运行php artisan migration -v命令,并收到此错误.

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.

现在我遇到此错误.

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.

异常跟踪:

创建一个路由器并查看连接到我创建的表的视图,以查看是否能够访问数据库变量并将其打印出来.返回时,我得到了这个错误.

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

推荐答案

我自己遇到了这个问题,并得到了错误Exception message: PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109

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

这是我修复它的方式:

我像这样以root用户身份登录mysql mysql –uroot –p并输入我的密码

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

您可以通过键入以下SELECT User, Host FROM mysql.user;

确保您看到正在尝试从.env文件连接到数据库的用户. 您将需要更改当前用户以使用最新版本的mysql所需的caching_sha2_password.

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.

这是该命令.

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

虽然仍以root用户身份登录,但是您需要运行此命令以允许您的用户执行允许php artisan migrate发生的所需任务.例如:CREATE, DROP, ALTER, DELETE等.

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';

希望这会有所帮助〜

这篇关于Laravel Migration停滞不前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆