Home>
**** An error occurred when I hit $php artisan migrate in Laravel.
I am working in a local environment.
I work while looking at the reference site on HP.
Error message
Illuminate \ Database \ QueryException: Database (/Users/name/Download/blog/database/database.sqlite) does not exist. (SQL: PRAGMA foreign_keys = ON;)
at /Users/name/Download/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660 | // If an exception occurs when attempting to run a query, we'll format the error
661 | // message to include the bindings with SQL, which will make this exception a
662 | // lot more helpful to the developer instead of just the database's errors.
663 | catch (Exception $e) {
>664 | throw new QueryException (
665 | $query, $this->prepareBindings ($bindings), $e
666 |);
667 |
668 |
Exception trace:
1 InvalidArgumentException: :( "Database (/Users/name/Download/blog/database/database.sqlite) does not exist.")
/Users/name/Download/blog/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php:34
2 Illuminate \ Database \ Connectors \ SQLiteConnector :: connect (["sqlite", "/Users/name/Download/blog/database/database.sqlite", "", "sqlite"])
/Users/name/Download/blog/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:218
Please use the argument -v to see more details.</Code></pre>
<p>Applicable source code</p>
<p>detabase.php</p>
<pre><code><? php
use Illuminate \ Support \ Str;
return [
/ *
| ------------------------------------------------- -------------------------
| Default Database Connection Name
| ------------------------------------------------- -------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
* /
'default' =>env ('DB_CONNECTION', 'mysql'),
/ *
| ------------------------------------------------- -------------------------
| Database Connections
| ------------------------------------------------- -------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
* /
'connections' =>[
'sqlite' =>[
'driver' =>'sqlite',
'url' =>env ('DATABASE_URL'),
'database' =>env ('DB_DATABASE', database_path ('database.sqlite')),
'prefix' =>'',
'foreign_key_constraints' =>env ('DB_FOREIGN_KEYS', true),
],'mysql' =>[
'driver' =>'mysql',
'url' =>env ('DATABASE_URL'),
'host' =>env ('DB_HOST', '127.0.0.1'),
'port' =>env ('DB_PORT', '3306'),
'database' =>env ('DB_DATABASE', 'forge'),
'username' =>env ('DB_USERNAME', 'forge'),
'password' =>env ('DB_PASSWORD', ''),
'unix_socket' =>env ('DB_SOCKET', ''),
'charset' =>'utf8mb4',
'collation' =>'utf8mb4_unicode_ci',
'prefix' =>'',
'prefix_indexes' =>true,
'strict' =>true,
'engine' =>null,
'options' =>extension_loaded ('pdo_mysql')? array_filter ([
PDO :: MYSQL_ATTR_SSL_CA =>env ('MYSQL_ATTR_SSL_CA'),
]): [],
],
'pgsql' =>[
'driver' =>'pgsql',
'url' =>env ('DATABASE_URL'),
'host' =>env ('DB_HOST', '127.0.0.1'),
'port' =>env ('DB_PORT', '5432'),
'database' =>env ('DB_DATABASE', 'forge'),
'username' =>env ('DB_USERNAME', 'forge'),
'password' =>env ('DB_PASSWORD', ''),
'charset' =>'utf8',
'prefix' =>'',
'prefix_indexes' =>true,
'schema' =>'public',
'sslmode' =>'prefer',
],
'sqlsrv' =>[
'driver' =>'sqlsrv',
'url' =>env ('DATABASE_URL'),
'host' =>env ('DB_HOST', 'localhost'),
'port' =>env ('DB_PORT', '1433'),
'database' =>env ('DB_DATABASE', 'forge'),
'username' =>env ('DB_USERNAME', 'forge'),
'password' =>env ('DB_PASSWORD', ''),
'charset' =>'utf8',
'prefix' =>'',
'prefix_indexes' =>true,
],
],
/ *
| ------------------------------------------------- -------------------------
| Migration Repository Table
| ------------------------------------------------- -------------------------
|
| This table keeps track of all the migrations that have already run for| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
* /
'migrations' =>'migrations',
/ *
| ------------------------------------------------- -------------------------
| Redis Databases
| ------------------------------------------------- -------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
such as APC or Memcached. Laravel makes it easy to dig right in.
|
* /
'redis' =>[
'client' =>env ('REDIS_CLIENT', 'predis'),
'options' =>[
'cluster' =>env ('REDIS_CLUSTER', 'predis'),
'prefix' =>env ('REDIS_PREFIX', Str :: slug (env ('APP_NAME', 'laravel'), '_') .'_ database_ '),
],
'default' =>[
'url' =>env ('REDIS_URL'),
'host' =>env ('REDIS_HOST', '127.0.0.1'),
'password' =>env ('REDIS_PASSWORD', null),
'port' =>env ('REDIS_PORT', 6379),
'database' =>env ('REDIS_DB', 0),
],
'cache' =>[
'url' =>env ('REDIS_URL'),
'host' =>env ('REDIS_HOST', '127.0.0.1'),
'password' =>env ('REDIS_PASSWORD', null),
'port' =>env ('REDIS_PORT', 6379),
'database' =>env ('REDIS_CACHE_DB', 1),
],
],
];
.env
DB_CONNECTION = sqlite
# DB_HOST = 127.0.0.1
# DB_PORT = 3306
# DB_DATABASE = laravel
# DB_USERNAME = root
#DB_PASSWORD =
-There was a similar case and I investigated it, but the error was not resolved.
I don't understand it enough, and I think it's a bad idea to investigate.
Additional
detabase.php
'default' =>env ('DB_CONNECTION', 'mysql'),
,
'default' =>env ('DB_CONNECTION', 'sqlite'),
I tried to change it to, but I couldn't.
-
Answer # 1
-
Answer # 2
I was creating database.sqlite in the database file, but I missed it because it was misspelled.
Thank you for your response.
Related articles
- [rails 6] rails db: migrate cannot be done on heroku
- ruby - heroku run rails db: cannot migrate
- unity sqlite cannot add data using unitykit
- cannot migrate in php-laravel mysql environment
- php - cannot migrate with docker mysql laravel
- cannot migrate to mysql container in docker
- Android solves the problem that sqlite cannot create new tables
- [ruby on rails] rake db: migrate loaderror: cannot load such file --sqlite3/sqlite3_native
- php - cannot migrate with laravel heroku mysql
- (laravel) (mysql) cannot migrate with heroku
- ruby on rails 5 - rails db: cannot migrate
- Solve the problem that Django migrate cannot find the table of appmodels
Related questions
- Laravel artisan has its own team
- php : Composer and artisan stopped working in Laravel 8 project after migration
- php : Laravel. Doctrine DBall doesn't work, what's the matter?
- sqlite - undefined array key 1
- undefined variable $user (view: c: \ workspace \ neomediaproject \ resources \ views \ homebladephp)
- when i give it to heroku, i get an error with php artisan migrate
- i want to remove bootstrap and jquery from laravel
- laravel screen is not displayed on localhost even after "php artisan serve"
- php artisan migrate: refresh --seed gives an error
- php - artisan migrate does not work could not find driver
You can see that there is no such file error, but you can just make it according to the sqlite procedure.
Snacks
But sqlite doesn't come out in practice.
I'm a long engineer, but I have never used it for anything other than answering with StackOverflow.
I think that MySQL or PostgreSQL that can be used crisply should include the functionality.