I have a fresh installation of Homestead 7.17.0, Laravel 5.7.2 and Laravel Nova 1.0.14 but when I try to login with a username and password I added to the user's table, I get the following error:
Illuminate\Database\QueryException SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `email` = user#email.com limit 1)
I'm sure the database configuration in my .env file is correct. Actually, I added the user via a and artisan command I've created and which prove the main app can connect to the database without problems.
Double check your port, when I used Homestead on my Mac the port was 3306 for running artisan commands but for loading the web application in a browser it needed to be 33060
Related
From root user, I can execute this command without any problems:
[root#freebsd ~/var/html/www]$ bin/console d:run-sql 'SELECT * from user';
From www user, I cannot execute this command:
[www#freebsd ~/var/html/www]$ bin/console d:run-sql 'SELECT * from user';
because I am getting the following error:
An exception occurred in driver: SQLSTATE[HY000] [2002] Permission denied
Both users are using the same config file:
parameters:
database_driver: "pdo_mysql"
database_url: "mysql://dbuser:dbuserpass#127.0.0.1:3306/dbname"
I am using MariaDB 10.4 which is running on Freebsd with PHP(Symfony project)
Authentication problems comes with an access denied message.
A permission denied error means that you authentication happened but the resource you're trying to access was denied. Probably the dbname database.
You need to grant at least a "select" permission to this user with root or another administrator user:
GRANT SELECT ON dbname.* TO dbuser#127.0.0.1;
Pay attention because with mysql client if we don't specify a host or specify it like localhost instead of 127.0.0.1, the client tries to connect trought unix socket.
You can overcome this with --protocol tcp or using a IP address.
I've attempted to access my PostgreSQL database from both a Laravel project, DBeaver and Artisan. Accessing it from Laravel project or Artisan ($ php artisan migrate) always results in:
Illuminate\Database\QueryException
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 5432?
Because I'm not relying in my Laradock settings and I'm not familiar with Laravel in general, I did re-download Laradock with default settings, but situation continues same.
Partial laravelProject/.env:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret
Partial laradock/.env:
POSTGRES_VERSION=alpine
POSTGRES_DB=default
POSTGRES_USER=default
POSTGRES_PASSWORD=secret
POSTGRES_PORT=5432
Environment used to run Artisan:
$ docker-compose exec --user=laradock workspace bash
I installed Laravel in this environment using composer global require laravel/installer.
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=yourprojectdatabase
DB_USERNAME=default
DB_PASSWORD=secret
To connect using DBeaver:
Host: localhost
Port: 5432
Database: you can leave it empty
Username: default
Password: secret
Click on the PostgreSQL tab right there in Connection.
Make sure "Show all databases" is checked.
I'm a beginner at Laravel and configuring MySQL.
I have a VM with Laravel 5.6 and MySQL 8. I've configured MySQL so I can log in with MySQL Workbench and everything is working well, but when I try to do a query in Laravel I get an error:
Illuminate \ Database \ QueryException (2002)
SQLSTATE[HY000] [2002] Connection timed out (SQL: select * from `users`)
My VM has a static IP of 192.168.56.3 and DHCP 192.168.56.1.
With MySQL Workbench I can connect with 192.168.56.3, but in Laravel this IP gives me an error:
PDOException (2006)
SQLSTATE[HY000] [2006] MySQL server has gone away
The other IP 192.168.56.1 gives me a timeout error.
My .env file is:
DB_CONNECTION=mysql
DB_HOST=192.168.56.3
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel_user
and my .cnf under [mysqld] is:
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
port = 3306
basedir = /usr
tmpdir = /tmp
#bind-address = 192.168.56.3
I know it's been a while but I've found the answer. Use the following command to update your password with new authentication plugin. You can use MySQL 8 now. Have fun.
ALTER USER `username`#`localhost` IDENTIFIED WITH caching_sha2_password BY 'password';
OR
ALTER USER 'username'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
I am using Sequel Pro on Mac and trying to see my database schemas that Laravel created. In the migrations folder I see a users and password reset tables. I am trying to see them in sequel pro which I do not.
I used homestead and the vagrant box is up. The homestead.yaml is set to defaults to:
IP: 192.168.10.10
MySQL db: homestead
In the .env file I see the defaults too:
IP: 127.0.0.1
MySQL: homestead
User: homestead
Password: secret
I try to use both IP's but can't seem to connect and if I do connect with 192.168.10.10 I see 0 tables. What am I missing? New to Vagrant and Laravel too.
You should try to declare the DB connection to
config/databases.php
note that you can declare multiple DB connections here if you don't use .env for course.
then try php artisan cache:clear
I can do migration to my homestead.
this is my .env
DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=54320
DB_DATABASE=intern
DB_USERNAME=homestead
DB_PASSWORD=secret
And I make a new server in my postgreSQL with
server name = Homestead,
username = homestead,
password = secret.
then, I did migration and all the table created into my database(server=homestead)
The problem is, when I want to do login in my site. It occurs an error:
SQLSTATE[08006] [7] could not connect to server: Connection refused↵
Is the server running on host "localhost" (::1) and accepting↵
TCP/IP connections on port 54320?↵could not connect to server: Connection refused↵
Is the server running on host "localhost" (127.0.0.1) and accepting↵
TCP/IP connections on port 54320? (SQL: select * from "users" where "email" = user#gmail.com limit
You have an extra 0 at the end of your port. Change DB_PORT=54320 to DB_PORT=5432
try to access your homestead with ssh.
i think u already change the password from the inside
from laravel documentation i think that config should work
or try this command after u change the config
php artisan config:cache and php artisan cache:clear
https://laravel.com/docs/5.6/homestead#connecting-to-databases