I am currently getting an error when I do my database migration with artisan with the command
sudo php artisan migration
I then get the following error:
SQLSTATE[28000][1045] Access denied for user 'root'#'localhost' (using password: NO).
I don't know where I would be able to reset the password or how and I have been looking for quite some time now. Any advice would be great. I am running this in a vagrant box. Thank you.
Edit your app/config/database.php file
Related
I am building a basic CRUD app using Laravel 7 Homestead in a Vagrant VM. The root address http://crud-app.local.test works, but when I add a defined route (http://crud-app.local.test/cats) I get this error page:
Error message in browser when navigating to '/cats' route.
So far I have:
Verified my MySQL password matches in the .env file and in practice
Changed the MYSQL password so that it's no longer empty (and made sure it matches what's in the .env file)
Ran php artisan config:cache
Ran php artisan config:clear followed by php artisan cache:clear
Changed 127.0.0.1 to localhost
Made sure the database defined in the .env file exists (crud)
Ran php artisan migrate (no errors, and the cats table exists in the crud database)
Restarted and re-provisioned the machine (vagrant reload --provision)
I'm at a loss now.
Make sure that you give "root" permissions to read from the database that you've created. As it's root#localhost rather than root#127.0.0.1 sometimes mysql differentiates. Just check the permissions that root#localhost has for the database and if you update them, flush the privileges.
I start to work on a laravel project that start by colleage. once I pulled down the git I want to do migration:
php artisan migrate:refresh
Immediately I got an error:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'172.19.0.1'
(using password: NO) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE
TABLE')
which seems odd because I checked all my config/database.php, .env, all point to 127.0.0.1 for mysql and not sure where 172.19.0.1 come from.
How can I debug this?
Please check your database, you have permissions issue for the database user.
Grant permissions for your db user root.
Execute the below command:
GRANT ALL PRIVILEGES ON dbname.* TO 'root'#'172.19.0.1';
FLUSH PRIVILEGES;
i cannot connect to database after clearing even php artisan is not working.
here is how i clear config caches:
php artisan cache:clear
then it's cleared successfully but when i run:
php artisan config:cache
i got this error:
<pre><strong>ERROR:</strong> Can't connect to the database server. SQLSTATE[HY000] [1045] Access denied for user ''#'localhost' (using password: NO)</pre>%
i also tried: composer dump-autoload
but still no luck. Once in the past i got same error and i was able to solve it but no idea how. If someone knows solution then kindly explain it as well.
My php version: PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 5 2018 05:00:15) ( NTS )
Thank you!
User you are using to connect the database in not having privilege to connect, please provide that access to your db user
I don't know if i'm allowed to answer my own question or not. Let me know if it's not allowed to answer to your question.
In bootstrap directory which is located in root of your app. There i saw cache directory and then i just delete it and run:
composer dump-autoload
then it's works. But even if i try to run:
php artisan config:cache
it gonna be successful. But if after this you may get same error again:
php artisan serve
ERROR: Can't connect to the database server. SQLSTATE[HY000] [1045] Access denied for user ''#'localhost' (using password: NO)
After this i try to delete config.php inside bootstrap/cache/.
it gonna work even after deleting that file.
I'm using Laravel 5 and when I am running php artisan route:list, it always gives me an error of SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES). This shouldn't be because my application will not be connecting to any database since it will be a static website.
I tried removing the variables on the .env file:
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Just still gives me errors. It seems like it is still connecting to the database wherein it shouldn't make any database connection.
I was experiencing the same issues when I upgraded my Laravel installer from v1.1 to v1.2.
It appears that the routes.php file by default is adding the Authentication route:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
This causes to display an error message to what you were describing:
$ php artisan route:list
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'forge'#'localhost' (using password: NO)
I resolved this by removing the scaffolding included within Laravel by executing the following command:
$ php artisan fresh
Or by simply deleting the Auth route within the file itself.
You should now be able to run: php artisan route:list
Hope this helps!
This might be the problem of localhost. Do check your WAMP, MAMP, LAMP and XAMP MySql server if you are using any of them.
This have solve my problem:
It looks like artisan might be working in the wrong environment. Run "php artisan tinker", then "App::environment();" to see which environment Artisan is running in. If it is something other than production, you need to create a folder with that environments name within your app/config folder, and put a copy of the "database.php" file in it.
After That if you are not doing any DB related task it will not access DB.
I found answer here
Alternatively You can run following command to resolve this issue:
php artisan migrate:install --env="local"
After this run you command:
php artisan route:list
Enjoy.
This seems like it should be pretty easy but I am running into problems trying to create a database following these instructions: http://symfony.com/doc/master/book/doctrine.html
I edit the parameters.yml and config.yml file and then run this command from terminal:
php app/console doctrine:database:create
The error I am getting is:
Could not create database for connection named `learn_symfony`
SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: YES)
How do I resolve this error and create the database?
The problem is that you are probably trying to connect on a server that isn't configured properly.
There is nothing to do with doctrine.
Tell me, are you trying to connect to a home-made server ? Is it a LAMP or WAMP stack ?
EDIT
If you are running on a recently installed server, you have to edit the MySQL configuration and set a password to the root account or set on the directive allowNullPassword
EDIT 2
If your server is LAMP, the file you have to change is located at /etc/my.cnf
EDIT 3
That file is for various mysql configurations.
About the allow null i was mistaking with phpMyAdmin.
Try setting a password for the root with this command
mysqladmin -u root password MYVERYNEWANDSECRETPASSWORD