How to use character '#' in #nest/config ".env.dev"? - configuration

Is there any way to use '#' in .env.dev file?
My MySQL password has '#'
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=mypass#word
DB_NAME=testdb
NODE_ENV=dev
this code recognized like 'mypass'

DB_PASSWORD='mypass#word' or DB_PASSWORD="mypass#word"

Related

how can I match Laravel .env with XAMPP configuration settings?

I changed XAMPP configuration ports and localhost, when I ran old project it doesn't work so I need anyone to help me to match the .env with XAMPP configuration
the XAMPP window
Apache Service Window
MySQL Service Window
the .env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:kuAaczKFkzJWGNlZzrPpsBsmv+NNMCMPVwTsNYsbZyc=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mobitech
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
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}"
If you want work Laravel with XAMPP, you need to check 2 things.
1- First your root folder must be laravel's public folder. So to do that click the Apache Config button and select the Apache httpd.conf option. Then find the DocumentRoot "C:/xampp/htdocs" and change with DocumentRoot "C:/xampp/htdocs/public"
2- Laravel's database options are in the .env file. XAMPP uses MySQL and its port is 3306. In the .env file DB_PORT key default value is also 3306. You you need to change port as your option (3308).
So when you enter the localhost or 127.0.0.1 probably it will work. But you had changed the http port as 1234, so you must enter https://localhost:1234 as an address.

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

How to configure .env file in lumen?

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

Can't migrate database( laravel)

I am facing problem migrating database using php artisan migrate command .
Can anybody help me figure out what I did wrong here?
Please note I am fairly new with laravel.
Set proper database connection in the .env file then restart your server. Then try to migrate. Hope it will helpful.
you DB_CONNECTION is a localhost put mysql
and your config/database 'default' => env('DB_CONNECTION', 'mysql'),
and your .env DB_CONNECTION=mysql
Your installation isn't pulling your username/password from your .env file and it's using the defaults. Assuming this is a new install of Laravel and you just edited .env.example then you need to rename that file to just .env:
You can run:
mv .env.example .env
set these in .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=fresher
DB_USERNAME=root
DB_PASSWORD=
give a try to these commands to cleanup things
1 - run composer dumpautoload
2 - run php artisan clear-compiled
after that run the php artisan migrate command