Getting laravel app Database running on local - php

Hey guys I'm new to PHP/Laravel, from a rails background. I pulled down an app via ssh that has certain database configurations and I cant for the life of me get this app running locally these are the errors I keep getting.
SQLSTATE[HY000] [1045] Access denied for user
'fatkikisManiak'#'localhost' (using password: YES)
For this error I noticed that it was trying to run the production configurations so I thought it best to change to a development config. I went into bootstrap/start.php and
$env = $app->detectEnvironment(array(
\\'local' => array('homestead', 'Username', 'password'),
'local' => array('MacBook-Pro'),
));
This gives me:
SQLSTATE[HY000] [1049] Unknown database 'fatkikis_local'
Any help on getting this resolved would be apprciated

Please check the .env file in the root folder and modify the database informations.
This is a hidden file.

Related

config sticked in laravel app on shared hosting

I've deploy a laravel API some months ago into a shared hosting (banahosting). It's been working fine until yesterday that all API endpoints returns an error:
Illuminate\Database\QueryException: SQLSTATE[HY000] [1045] Access denied for user '####'#'localhost' (using password: YES) (SQL: select `destinations`.*, (select count(*) from `experiences` where `destinations`.`id` = `experiences`.`destination_id`) as `experiences_count` from `destinations` order by `id` desc) in file /###/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 669
Its weird because no-one else than me has access to the hosting, so i supposed that maybe some strange security function of this shared hosting has changed the password of the db user so i just changed it again, updated the .env file and ran the commands to clear artisan cache but the error has remained.
I've tried creating a new DB user and then i found the real problem: even when i changed the db user on the .env file, the error says that the user which is trying to access is the same. I mean, the error should say something like "Access denied for user 'NEW_USER'#'localhost'" but instead it says "Access denied for user 'OLD_USER'#'localhost'"
I also tried setting directly the user and password into the file /config/database.php or deleting completely the .env file but the error is exactly the same.
The support team of the hosting tried to help me too, they told me that they cleaned the cache of the server but it didn't work and they don't know what could be happening.
The command after every changed i've tried is php artisan config:clear and php artisan config:cache, i've also tried with php artisan config:clear and php artisan optimize

MySQL+Laravel: SQLSTATE[HY000] [1045] Access denied for user 'so'#'localhost' but connection data is OK and config cache is cleared

I need help here, because it's driving me crazy. I'm trying to connect to the remote production DB but I'm unable. I have read tons of posts about this that are focusing on the credentials and also running the following commands to clean config that are stored in Laravel cache:
php artisan cache:clear
php artisan config:cache
php artisan config:clear
Laravel 5 error SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES)
Any of these are working for me.
I have checked very well the credentials both in my .env file and my database.php. I'm able to connect to a local database by using the ip "127.0.0.1" but I'm unable with the production DB stored in Google Cloud. It's good to mention that my local IP is allowed to access that Database and I'm able to connect by using MySql Workbench.
Here is what I see when I perform "php artisan tinker" and then "DB::connection()->getPdo();" to check my connection from terminal:
The only thing that calls my attention is the message containing "so#localhost" when I'm not performing a connection to localhost but I don't know if that's related with the issue.
Any other suggestion? I have lost too much time trying to find out what could be happening.
EDIT 1: Laravel Framework 5.8.38
After two days fighting with this one, I readed tons of posts and a lot of unuseful solutions I have found my solution by looking at this video.
Basically, you must stop you XAMPP MySQL Server and open C:\xampp\mysql\bin\my.ini and edit by adding the following command "skip-grant-tables" after the [mysqld] attribute. The result in this file might look this way:
# The MySQL server
default-character-set=utf8mb4
[mysqld]
skip-grant-tables
socket="C:/xampp/mysql/mysql.sock"
...
After that, I ran "php artisan tinker" and DB::connection()->getPdo(); and everything was connected again, but it's good if you first clean your cache and config.

Upload Local Laravel Project to Server

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

Laravel doesn't detect my local (development) database config file

My Laravel application is running on my local computer. When I run my app, Laravel uses my production database configuration and throws an Exception:
SQLSTATE[HY000] [1045] Access denied for user 'production_admin'#'localhost' (using password: YES)
This is strange because when I check current environment using artisan it says :
Current application environment: development
and my development database config file has a different username and password.
also I have stated in bootstrap/start.php that :
$env = $app->detectEnvironment(array(
'development' => array('*.dev', gethostname()),
'production' => array('*.com', '*.net', '*.org', '*.ir')
));
I don't know why Laravel insist on using production configuration although I'm in development environment.
Thanks for your help.
The best way to avoid this issue is to do the following:
in /bootstrap/start.php
Replace the default environment detection with:
$env = $app->detectEnvironment(function()
{
return getenv('APP_ENV') ?: 'local';
});
This will check for the presence of an environmental variable which is set by apache/nginx assuming you are running Homestead or similar.

laravel4 migration failed (pdo exception)

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.

Categories