DB_HOST and Browser Settings For Laravel App - laravel

I'm putting together a Laravel 5.2 application and using Homestead with it. When I need to migrate my database these are the settings that I have set up that allows me to do migrate. However if I want to use these in my browswer then I have to switch 127.0.0.1 to localhost. Why do I have to do this and how do I fix that?
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Anybody have any ideas on this?

if you are using wamp do like this:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=mysql
DB_USERNAME=root
DB_PASSWORD=
mysql is your database .you can access it by going localhost/phpmyadmin

I was able to find out that I need to keep it as DB_PORT=3306 and only use 33060 for when I'm trying to access the database with a program like Sequel Pro.

Related

How to Connect to Database SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)

I got this error when i tried to connect to my database:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES) (SQL: select active_template from general_settings limit 1)
I'm new to laravel so i'm sorry if it's a common question because i try to find the solution and see similar problems but not exactly the same.
I tried to change my .env files and use no pass for the db and restart the server but it is still getting the same error. Here's what my env files look like:
APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:xxx
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database123
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
what should i do? thankyou
Try to make another MySQL user, and grant all privileges to ONLY that database. Mostly root user is denied from shared hosting since i check your APP_ENV is on production.
Hope this helpful
https://phoenixnap.com/kb/how-to-create-new-mysql-user-account-grant-privileges
try php artisan config:cache and php artisan cache:clear after changing your .env file

No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6037]

No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6037] (View: C:\laragon\www\Project CRM\resources\views\users\index.blade.php)
keep getting the error in my laravel project , it only appears in my specific module of users and when i login with the user credentials , otherwise it does not affect my other modules of the code
my env file is
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=daybyday
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=6037
any idea what is causing this error ?
thanks in advance
The redis server was not started and the port number was wrong in my env file

laravel .env folder's db config, hosting it on mamp

I just wanted to check is there some Username and Password in my MAMP account that I must add to .env file
more exactly what should this part in .env be, when using MAMP
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=
when hosting my server is being hosted at localhost/8888 maybe I should change DB_HOST from 127.0.0.1 to localhost/8888?
and what to do with Username and Password?
DB_HOST must an IP or a hostname and it's not related to a folder. Just input user name and password that you created. Usually default username and password for MAMP is root.

Laravel Homestead could not connect to server 127.0.0.1

I have installed laravel homestead and vagrant. After vagrant up my local site started work.
My migrations worked well and i could connect to DB with PhpStorm ( http://joxi.ru/a2X45M1S1x3Vw2 )
my .env file contains the same code as written in doc
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=54320
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
But when I try to register new user I got an error
SQLSTATE[08006] [7] could not connect to server: Connection refused Is
the server running on host "127.0.0.1" and accepting TCP/IP
connections on port 54320?
( http://joxi.ru/nAynW7asYOD39r )
How it possible when migrations run well but connection refused?
Your screenshot says that Laravel is having trouble connecting to 192.168.10.10, which isn't the same as 127.0.0.1. Check that the correct DB_HOST is set in your .env file.
In case the config from the .env file isn't being used, also check the config/database.php file and verify the settings there too.
You have to change .env -> DB_PORT
for pgsql use DB_PORT=5432
I was having this same issue, and what worked for me was to change my DB_HOST=127.0.0.1 to ip: "192.168.56.56"(the same id that is on my Homestead.yaml file).

SQLSTATE[HY000] [2002] Connection refused after update XAMPP with PHP 7.2 on mac

Everything worked fine until I update XAMPP with PHP from 7.1 to 7.2. I noticed to access phpmyadmin using this new XAMPP on mac, need port 8080 (http://localhost:8080/phpmyadmin). Is this the problem? I already tried to change DB_HOST from 127.0.0.1 to localhost but nothing works.
Here my .env looks like
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=''

Resources