How to configure .env file in lumen? - mysql

I have tried searching and asking friends, the internet or on this site but all failed, I want to migrate database in lumen and this is my .env setting
APP_NAME=Lumen
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_twin
DB_USERNAME=root
DB_PASSWORD=root
UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
so when I enter php artisan migrate, I got this error
In Connection.php line 664:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = db_twin and table_name = migrations)
In Connector.php line 70:
SQLSTATE[HY000] [2002] No such file or directory
Thanks for your answer

Related

SQLSTATE[HY000] [2006] MySQL server has gone away laravel mysql and xampp

i am using laravel 7 with a xampp installation. php artisan migrate fails and gives the error: SQLSTATE[HY000] [2006] MySQL server has gone away
my .env file:
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=****_db
DB_USERNAME=root
DB_PASSWORD=*******
i have tried localhost in the env file isntead of 127.0.0.1. Worth mentioning that my xampp application launches at this address: http://192.168.64.2/
i have started and restated the xampp server and i have been php artisan cache:clear each time i make changes to the .env file
I ended up ditching connecting to my local xampp installation and connected to an AWS RDS instance and it worked.

Keep getting Undefined variable: DATABASE_URL error on Laravel - MySql

I keep getting
PHP Notice: Undefined variable: DATABASE_URL in ....../config/database.php`
error when running
php artisan migrate:fresh --force`
My .env file consist of
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xxxxx
DB_USERNAME=xxxxx
DB_PASSWORD=xxxx
DATABASE_URL=mysql://xxxxx:xxxxx#127.0.0.1:3306/xxxxx
I'm not sure why this is showing up.
Do use only one
Either
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xxxxx
DB_USERNAME=xxxxx
DB_PASSWORD=xxxx
Or,
DATABASE_URL=mysql://xxxxx:xxxxx#127.0.0.1:3306/xxxxx
DATABASE_URL contains all the database config, i.e. DB_CONNECTION, DB_HOST, etc.

Illuminate\Database\QueryException : SQLSTATE[HY000] [1044] Access denied for user ''#'localhost' to database 'forge'

I have downloaded a repo on github and created a database. I am trying to do migrations and am getting the below error
Error:
Illuminate\Database\QueryException : SQLSTATE[HY000] [1044] Access denied for user ''#'localhost' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')
This is my .env file
APP_NAME=Tafuta
APP_ENV=local
APP_KEY=base64:0IDLuBYdTssK55SeeQTmCJ3GHlJXsR6BahTeenXaf90=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=TafutaM
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
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
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
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}"
Your .env is not taken into consideration for the variables.
It might be cause by something in your Vhost configuration like
A direct declaration of the variable in there that would override .env variables.
Another environment file is declared it it to be read. like .env.prod or .env.dev
Many people have this common error: It's because your database is not set.
Error say: '#localhost', then username = ''
database: forge, then database is named = 'forge'
If you dont see that parameters into your .env, its because file is not read, then you have to refresh your configuration:
php artisan config:cache
if you are using php artisan serve cancel it, and run again.
Now, if problem persists, you have to log with terminal or a database tool to your database, and make sure that the next parameters are the same:
DB_CONNECTION=
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
Sometimes, people set incorrect port, or username or any(dont forget refresh configuration if you edit .env file).
You have to run the following command if you downloaded the source from GitHub:
composer install
cp .env.example .env
php artisan key:generate
php artisan config:clear
php artisan cache:clear
php artisan migrate

Remote Database is connecting

I am using laravel to build a project it was working then my server went offline(i am using another workstation just for database and other purposes)after the workstation restart then I couldn't login into my site it throws this error
SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
my env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=ipaddress
DB_PORT=3306
DB_DATABASE=ssweb
DB_USERNAME=user
DB_PASSWORD=password
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=300
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
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}"
It means you cant connect to the server. Check your connecting to the correct ip address and your firewall is configured to allow traffic.

PDOException in Connector.php line 119: could not find driver

I installed Laravel 5.3 on CentOS 6.8. I updated php to 5.6.27, installed mysql-pdo, php-pdo.
In phpinfo(): PDO drivers: sqllite SQLite Library 3.6.20
But when I get data from DTB, I still get error:
PDOException in Connector.php line 119: could not find driver.
I did some search online, and one of solutions is:
uncommented ;extension=php_pdo_mysql.dll,
but I can't find it in my ect/php.ini file. when I add it manually, I got the message "
php startup unable to load dynamic library php_pdo_mysql.dll ...
" in php artisan migrate, and the error display in web is still the same.
Here's my env file:
APP_ENV=local
APP_KEY=base64:*somekey*
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydtb
DB_USERNAME=myusername
DB_PASSWORD=mypass
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
My website address is 192.168.1.100 in local.
Can anyone help me with this?