I've created a Laravel 5.3 project on my local apache server(XAMPP) and it works fine with login and registration.
However, when I upload(via FTP) to my server(the server is 000webhosting) and try to do login it returns an error saying:
PDOException in Connector.php line 119:
SQLSTATE[HY000] [2002] Connection refused
I've already changed the .env to match the server DB's info, and just in case I also changed the config/database.php to also match. But it still appears like that?
Do you know exactly everything I have to change in my project so it can work on the server?
May be Your database password changed in live. update .env file
Related
i am new at AWS lightsail, basically just following the instruction step by step create a instance, create a database named mypost, and upload all file to instance by filezilla, and then use potty to connect phpmyadmin, export local database into online database, but somehow when i test the link on browser it tell me Connection Error: SQLSTATE[HY000] [1049] Unknown database 'mypost' , i checked both phpmyadmin and database in the aws console all named mypost, i also switched to public mode as well, anyone know why is it?
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.
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 have deployed a web app to heroku and everything seemed to be okay. I ran the migration and it was successful.
When I try to open the app in a browser am getting the below error, what could be the problem? Having in mind the migration was successful and when I access the heroku DB from my localhost it is working well.
production.ERROR: InvalidArgumentException: Database [database]
not configured. in /app/bootstrap/cache/compiled.php:11774
Kindly help.
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.