Open fusionsec opened 3 years ago
Hi
This is likely because you haven't change the .env, forge is the default database name.
Fix:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Hi Katie,
I made the necessary change by copying the .env.example and renamed to .env file as noted, included pw for root, and getting the same error. I also did an uninstall and reinstall with the changes, and getting same error again.
Thanks for your assistance.
Try clearing the cache php artisan config:cache
If that does work you can force the database connection by going into config/database.php
I cleared the php artiscan cache, same error afterwards.
Question about force db connections in config/databse.php file. I'm not sure about what you mean for "forced" db connection but I did chage the db name to "laravel" and included pw, saved and ran php artiscan migrate and got error :"Access denied for user 'root'@'localhost'
mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'laravel'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', 'password'), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
HI Katie,
After another install, and all the changes you recommended I'm now getting a new error:
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
at C:\Generic-University\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) {
671| throw new QueryException( 672| $query, $this->prepareBindings($bindings), $e 673| ); 674| } 675|
1 C:\Generic-University\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)")
2 C:\Generic-University\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:41 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException))
Thanks for your assistance.
database.php
人
Run this command on mysql window GRANT ALL on <your db name>.* to <your user name>@localhost
I found this on after two days searching. Hope it will work for you :D
Instead of using IP in the .env file try to use localhost
like this: DB_HOST=localhost
I guess you didn't create table in database try to create one
I'm also receiving the same error. Have Googled it for hours but no solution will work
C:\Laravel\laravelblog>php artisan migrate
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravelblog and table_name = migrations and table_type = 'BASE TABLE')
at C:\Laravel\laravelblog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:692 688▕ // If an exception occurs when attempting to run a query, we'll format the error 689▕ // message to include the bindings with SQL, which will make this exception a 690▕ // lot more helpful to the developer instead of just the database's errors. 691▕ catch (Exception $e) { ➜ 692▕ throw new QueryException( 693▕ $query, $this->prepareBindings($bindings), $e 694▕ ); 695▕ } 696▕ }
1 C:\Laravel\laravelblog\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)")
2 C:\Laravel\laravelblog\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDO::__construct()
Hi
Access denied for user 'root'@'localhost' (using password: YES)
Usually means the username/password combo is wrong or that you haven't granted permission for your user to access the database. To fix, run these in your command line
mysql
or sudo mysql -uroot -p
You should now see:
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Then type:
1) CREATE USER 'uni'@'localhost' IDENTIFIED BY 'password';
2) GRANT ALL PRIVILEGES ON * . * TO 'uni'@'localhost';
3) FLUSH PRIVILEGES;
4) CREATE DATABASE 'generic';
5) and finally exit
Now go to /.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=generic
DB_USERNAME=uni
DB_PASSWORD=password
I hope this helps
Katie
I'm getting below error, tried changing DB ports as well.
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = my_blog and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703 699▕ // If an exception occurs when attempting to run a query, we'll format the error 700▕ // message to include the bindings with SQL, which will make this exception a 701▕ // lot more helpful to the developer instead of just the database's errors. 702▕ catch (Exception $e) { ➜ 703▕ throw new QueryException( 704▕ $query, $this->prepareBindings($bindings), $e 705▕ ); 706▕ } 707▕ }
+36 vendor frames
37 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I Am Also Getting Same error
I'm getting below error, tried changing DB ports as well.
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = my_blog and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703 699▕ // If an exception occurs when attempting to run a query, we'll format the error 700▕ // message to include the bindings with SQL, which will make this exception a 701▕ // lot more helpful to the developer instead of just the database's errors. 702▕ catch (Exception $e) { ➜ 703▕ throw new QueryException( 704▕ $query, $this->prepareBindings($bindings), $e 705▕ ); 706▕ } 707▕ }
+36 vendor frames
37 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
You Got The Solution On This
I got the solution. 1st create the db and make sure the db name is the same as in the .env file. Then run php artisan migrate.
Do you have any links for remote PHP, Laravel, Django, JavaScript jobs.
You can check out my portfolio http: tafadzwamunyuki.epizy.com
On Thursday, October 14, 2021, Ronak Ramwani @.***> wrote:
I Am Also Getting Same error
I'm getting below error, tried changing DB ports as well.
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = my_blog and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703 699▕ // If an exception occurs when attempting to run a query, we'll format the error 700▕ // message to include the bindings with SQL, which will make this exception a 701▕ // lot more helpful to the developer instead of just the database's errors. 702▕ catch (Exception $e) { ➜ 703▕ throw new QueryException( 704▕ $query, $this->prepareBindings($bindings), $e 705▕ ); 706▕ } 707▕ }
+36 vendor frames
37 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\ Component\Console\Input\ArgvInput), Object(Symfony\Component\ Console\Output\ConsoleOutput))
You Got The Solution On This
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/InsiderPhD/Generic-University/issues/12#issuecomment-943223945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMXOI6K4Z7HTJFSIB6CRKLUG2VYBANCNFSM4R3FAEOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- Tafadzwa Munyuki
Try clearing the cache
php artisan config:cache
If that does work you can force the database connection by going into
config/database.php
I ran php artisan config:cache
and works for me
I found the cause of the error and 90% of you will solve the problem in this way. I changed the port from mysqlin .ini file to 3306 to 4306 because mysql doesn't work, but I didn't specify it in .env file. then after changing the port in the .env file to 4306, we write the code "php artisan config: cache" to the terminal and then migrate. I hope this will help you!
hello, i gettig run php artisan migrat
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
at C:\Users\Rishu\laravel\vendor\laravel\framework\src\Illuminate\Database\Connection.php:759
755▕ // If an exception occurs when attempting to run a query, we'll format the error
756▕ // message to include the bindings with SQL, which will make this exception a
757▕ // lot more helpful to the developer instead of just the database's errors.
758▕ catch (Exception $e) {
➜ 759▕ throw new QueryException(
760▕ $query, $this->prepareBindings($bindings), $e
761▕ );
762▕ }
763▕ }
1 C:\Users\Rishu\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)")
2 C:\Users\Rishu\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])
could not find driver (Connection: mysql, SQL: select * from sessions
where id
= UYofquFKQ4WFgne0pSIg6DCkTjPUENaZ7diF3968 limit 1)
i am facing this issue
Hello,
I'm getting error after running php artisan migrate:
SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')
at C:\Generic-University\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) {
1 C:\Generic-University\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)")
2 C:\Generic-University\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:40 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException))
I'm using XAMPP for Windows for the DBs, and under Mysql here are the users: MariaDB [mysql]> SELECT User, Host FROM mysql.user; +------+-----------+ | User | Host | +------+-----------+ | root | 127.0.0.1 | | root | ::1 | | pma | localhost | | root | localhost | +------+-----------+
Thanks for any assistance.