How would I go about doing this (the title is the question), I've changed all my ENV files to my hosted mysql details. When i run php artisan migrate from composer I get the
"denied username#localhost using password yes error".
I've changed the port and everything but I'm not sure what to do anymore and I'm 99% sure that the details are correct I've tried them multiple times
You need check somethings:
are credentials valid (username, password and host)?
the database host is accessible by your application server?
.env file is correctly configured or have some config hard coded in app/config/database.php?
To validade connection, you can try this: http://www.w3schools.com/php/php_mysql_connect.asp
About configuration and enviroments : https://laravel.com/docs/5.2/configuration
Related
I'm trying to access a database (which exists on a different server) on my Laravel application. I keep getting the following error: SQLSTATE[HY000] [2002] Permission denied
My .env file is set up as follows (changed a bit to protect privacy):
DB_CONNECTION=mysql
DB_HOST= IP_ADDRESS
DB_PORT=3306
DB_DATABASE=DB_NAME
DB_USERNAME="laravel_user"
DB_PASSWORD="password"
I'm not sure if this is important or not but I can access the web server's database if I go to the link IP.ADDRESS/phpmyadmin
My web.php file is as follows:
Route::get('/test', function(){
return DB::select("select * from umts_list");
});
Additionally, I also went to IP_ADDRESS/phpmyadmin (where my database exists) and added a new user called laravel_user with the ability to SELECT all data and saved it with the 'password' as its password.
My attempt: I tried whatever I mentioned above and also cleared the cache since I made changes to the .env file by entering the following commands:
php artisan config: clear
php artisan cache: clear
Any help would be appreciated. Thank you.
Edit 1: On phpMyAdmin, I made sure to add the user as depicted by the following picture:
PhpMyAdmin User Account
Additionally, I also checked the port number on phpMyadmin and it is 3306 as depicted by the following image:
Port Number
just in case anyone else stumbles upon this post in the future, it turns out that I did not have to create an SSH tunnel or whitelist the IP. The problem was actually with SELinux. This post was the solution: Laravel permission denied on remote Mysql server (AWS aurora)
Specifically, I ran the command: sudo setsebool -P httpd_can_network_connect_db=1
This worked perfectly and it was actually blocking connection to remote databases.
Couldn't connect to the database with laravel 6.0
SQL user and password were working fine and running smoothly on other project but the same credentials are not working on laravel 6.
I have created another user and give it all permissions but still got the same error.
I had cleared all kind of laravel cache,
remove the bootstrap and storage cache but nothing happened.
Please help me to solve this problem.
OS version: ubuntu 18.04
Server: nginx
Database: mysql 5.7.28
PHP: 7.2
Sharp(#) character recognizes as comment in .env file.
So you should put your password in double quotes("")
like this:
DB_PASSWORD="xfs#sds"
I have a larvael and I want it to make it in production. I have a server hosting and database on infomaniak.com.
I have upload all my file and I get a SQL timeout error :
SQLSTATE[HY000] [2002] Connection timed out (SQL: select * from
characters where checked = 1 order by RAND() limit 1)
I have an other Laravel website on infomaniak and don't have this problem. I have check my .env file, my /config/database file and try php artisan config:clear or php artisan cache:clear. I also try to dump DB:connection() and the connection information are right.
I can connect to my homestead database in local and work fine. But when I try to connect to the SAME database than my other website with the same .env file and still have the timeout error.
How can I fix this ? Are there a way to clear another cache ? Completly lost :/
EDIT :
If i try :
if(DB::connection()->getDatabaseName()) {
echo "Yes! successfully connected to the DB: " . DB::connection()->getDatabaseName();
}
The page return Yes! successfully connected to the DB: db_name
EDIT 2 :
I just see my hosting server is in PHP 5.6 but it say that's my website is in PHP 7. Really confusing but maybe this informations is important (have another laravel on this server and works like that)
Your problem is the php version, if you're using laravel 5.5 then your host must have php 7 installed.
See the oficial docs here
I already asked a question about this 2 days ago, here are the links
Got "password authentication failed for user" but in pgAdmin 3 its working
But I still didn't get an answer to solve the problem.
So I tried to create a new laravel project, then edit the .env file, check if php artisan migrate can run.
After I run php artisan migrate it's running, so it means that my credentials to PostgreSQL database are correct right? if not it will tell you password authentication failed for user "postgres", but I don't get any error at all, so I go to the next step. Now after I make sure everything is OK i run php artisan make:auth, it's a success without error at all, so I go to the web browser then run the site, I clicked the register / login button, fill the fields, submit then, it's happened again the nightmare
I got this message from the website
SQLSTATE[08006] [7] FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" (SQL: select count(*) as aggregate from "users" where "email" = test#test.com)
Even though php artisan migrate run really well, so I've no idea why it's happening. Is there somebody that ever run into this problem before? or maybe why it's happening?
I already search all keywords that possible to fix this problem, but I can't found the answer, it's really stressed me out.
for the info I'm using:
PostgreSQL 9.6.8
Laravel 5.6
Ubuntu 17.10
Edited: Here is my pg_hba.conf
Check your database.php file in config directory, and check the pgsql array. If accessing DB credential values from .env not worked there, test it by directly putting credentials there. hope it will help. Artisan commands work by accessing the credentials from .env files directly,not from database.php that's why migration worked.
I had a similar problem, my generated password contained the character: '#'. This made it a comment line, ignoring the rest of the password. I just changed my password.
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.