Laravel php artisan migrate not working

若如初见. 提交于 2020-03-18 15:20:32

问题


When I try to use 'php artisan migrate' in Laravel I get 2 errors:

[Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 26 file is encrypted or is not a database (SQL: select * from sqlite_master where type = 'table' and name = migrations)

[PDOException] SQLSTATE[HY000]: General error: 26 file is encrypted or is not a database

I created a storage/database.sqlite file before attempting the migration. I also edited the config/database.php, making the default=sqlite. I am using windows and have sqlite3 installed.

Has anyone encountered this/know how to get past it?


回答1:


I had the same results, in my case the /database/database.sqlite file was not empty.

I deleted the contents reran php artisan migrate and the migration table was created successfully.




回答2:


Running Laravel in Windows under the Powershell console I was getting the same errors as the original poster. The documentation reads After creating a new SQLite database using a command such as touch database/database.sqlite... The Powershell equivalent of touch is typically Out-File FILENAME

PS D:\Learning\PHP-Laravel\database> out-file database.sqlite
PS D:\Learning\PHP-Laravel> php artisan migrate
   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 26 file is not a database...

When creating my database.sqlite file I received these errors. I deleted the database and recreated it using the New-Item command and it worked properly

new-item -ItemType File -Name database.sqlite
PS D:\Learning\PHP-Laravel> php artisan migrate
Migration table created successfully.



回答3:


Check the file you made as .sqlite and make sure it is empty if not then make it empty

database/db.sqlite 

then run migration




回答4:


If somebody came here with the same error with manually created table in sqlite db - it could be the sqlite version mismatch. I solved the same error by emptying db file and recreate the table with getConnection()->statement('CREATE TABLE



来源:https://stackoverflow.com/questions/32693754/laravel-php-artisan-migrate-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!