Laravel 5 迁移错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31671083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:03:58  来源:igfitidea点击:

Laravel 5 migration error

phpmysqllaravelmigrationlaravel-5

提问by Gammer

I was using migration with a database. Then i removed that database and created new one. Then i created migration files from the terminal via php artisan make:migration create_users.

我正在使用带有数据库的迁移。然后我删除了该数据库并创建了新的数据库。然后我通过终端从终端创建了迁移文件php artisan make:migration create_users

Then i came back and tried to run the migration and it throws the following error with php artisan migrate

然后我回来并尝试运行迁移,它抛出以下错误 php artisan migrate

Error:

错误:

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/opt/lampp/htdocs/laravel/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /opt/lampp/htdocs/laravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:95

PHP 致命错误:未捕获异常“UnexpectedValueException”,消息为“无法打开流或文件“/opt/lampp/htdocs/laravel/storage/logs/laravel.log”:无法打开流:/opt 中的权限被拒绝/lampp/htdocs/laravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:95

And also a few more.

还有一些。

I googled and found that composer dump-autoloadwil work, But it didn't and composer dump-autoloadthrows the same error.

我用谷歌搜索并发现这将composer dump-autoload起作用,但它没有并composer dump-autoload引发相同的错误。

php artisan migrate:resetthrows the same error as php artisan migrate:reset.

php artisan migrate:reset抛出相同的错误php artisan migrate:reset

Thanks

谢谢

回答by Prashant Srivastav

Change Permission of log folder of laravel

更改laravel日志文件夹的权限

Give Read & Write permission

授予读写权限

storage/logs

Changing Database:

更改数据库:

1: Change DB name in config/database.php

1: 在 config/database.php 中更改数据库名称

2: root/.env DB_DATABASE=databasename

2: root/.env DB_DATABASE=databasename

回答by Maxim Lanin

It's not the problem of autoloading. It is a problem of file permissions. Check if webserver can write to the storage/logsdirectory.

这不是自动加载的问题。是文件权限问题。检查网络服务器是否可以写入storage/logs目录。