How to fix "Database (database.sqlite) does not exist." in Laravel? - php

I'm studying laravel then I switched mysql from sqlite. I deleted the database.sqlite file, configure the database.php to mysql and .env file.
I'm having a error "Database (database.sqlite) does not exist". How to fix this error?

The sqlite driver doesn't create the database file if it doesn't exist.
The simple solution is to create an empty file just before migrating the database into it (filling the file with schemas and data)
Simply put, this command will fix it:
touch database/database.sqlite

You don't need anything in the .env file except the DB_CONNECTION key/value pair. When you are using SQLite, remove all of the following keys:
DB_HOST
DB_PORT
DB_DATABASE
DB_USERNAME
DB_PASSWORD

If the above solution can not handle the current issue. click here
Issue with SQLite and Laravel on Heroku

Related

Laravel - User Access denied

I created my first App, using Laravel in the Backend. Everything was running on my localhost and I deployed everything to my Netcup Webhosting Server.
I run composer install successfully, generated the API key by using php artisan key:generate --ansi and set up my .env file. The File looks like:
APP_NAME="App Name"
APP_ENV=prod
APP_KEY=base64_key
APP_DEBUG=false
APP_URL=https://xx.xxxxx.de
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME="db_user"
DB_PASSWORD="db_user_password"
The I want to create all the database tables by using php artisan migrate. I tripple checked the values set in the .env and red a lot of solutions of other posts, but nothing worked. I keep getting the following error:
I already added quotes to DB_User and Pasword in .env file. I restarted the server several times and cleaned the cache.
It looks like some problems with auth on the Netcup Web hosting Server. Can you check list of user with access to db_name? Besides, by screenshoot I guessing that hosting add prefix ("k177581_") for db_name and db_user
Solved the issue:
As #N69S correctly suggested it was related to Netcup. For any other Netcup user the following solution.
Netcup devides its Webhosting and Database. Therefore you need to put you Database IP into your .env file. That can be found in the connection data.

Laravel Database Connection Error Illuminate\Database\QueryException

I have the problem with database connection after i ran a migration which is Illuminate\Database\QueryException. I've tried to ran the "php artisan migrate:fresh" command, but it didn't work. What should I do? Thanks in advance.
Here is the image
Check your php path in environment variables, php path must be of XAMP i.e "C:\xampp\php". Set this and then try to migrate again

Laravel testing database migration fails due to Passport

I installed Laravel Passport and migrated the new tables just fine in my database. But when I try to run migrations for the testing database, ie. artisan migrate --database=testing I get:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oauth_auth_codes' already exists
The only table that exists in the testing database is the migrations table. It looks as if it's checking the regular database and seeing this Passport table instead of checking the testing database. Did I miss something simple here?
php artisan ... commands will use your .env variables for configuration, so yes, unless you specified which database connection to use, it will use your default .env's DB_ variables.
You can define something like a .env.testing, then re-run as php artisan migrate --env=testing to use that file instead of your default one.
.env:
DB_CONNECTION=mysql
DB_DATABASE=database
...
# Host, Port, Username, Password,
.env.testing:
DB_CONNECTION=mysql
DB_DATABASE=testing
...
# Host, Port, Username, Password,

PHP, SQLite on windows using doctrine

i must connect to sqlite db file using doctrine,
when i copy db file to php(composer) project i can easily connect to DB,
but when i try to make absolute path it says SQLSTATE[HY000] [14] unable to open database file
i'm using symfony4.2 project for it and doctrine2.5
my .env is like this
DATABASE_WSW="sqlite:////C:\\Program Files\\programX\\db.sqlite" or
DATABASE_WSW="sqlite:////C:\Program Files\programX\db.sqlite" or
DATABASE_WSW="sqlite:////C:/Program Files/programX/db.sqlite"
above examples don't work
when used like this works:
DATABASE_WSW=sqlite:///db.sqlite
what I'm doing wrong?

laravel4 migration failed (pdo exception)

I just used artisan migrate to create some table, but I get an error of Type PDO:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
A php/mysql testscript could connect to the database just fine, but it was another virtualhost and it did not use PDO.
In Laravel4 edited app/config/local/database.php to set the password and database name.
edit in start.php
UPDATE
I hardcoded the password in the PDO connection array and now terminal says there is no database named "database". Clearly it is looking somewhere else for the config, but I have no other config file.
(Due to following a tutorial about making a "local" directory it was not working for me)As it stands, I have downloaded the stable version and everything is working great.
I am going to delete this post, to keep the forum clean.
Make sure you have set up your database connection correctly in app/config/database
Laravel Database Docs
Make sure you are setting up a 'local' environment in start.php
Otherwise Laravel will look for DB config in app/config/database.php
Kindly Check Your app/config/database.php file in local host.
1.)Make Sure local Host Data Base name is Correct
2.)Make sure local Host Data Base username is correct.
3.)Make sure local Host Data Base password is correct.

Categories