SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
chaoslucifer
Posts: 7
Joined: 03 Jun 2022, 17:50

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by chaoslucifer » 03 Jun 2022, 18:29

I kept on running into the following errors

I install XAMPP and Composer first then tried to running the following cmd:
composer create-project aimeos/aimeos myshop
and it ran fine in command prompt.

and everything seem successful until the following when creating the database. To create the database i just follow the following instruction but i sure i might be missing some steps maybe? I am also not to sure about the .env as i tried playing around with a few suggested changes but seem to do nothing... I did following suggestion from this link:

viewtopic.php?f=18&t=871&p=3654&hilit=S ... t%27#p3654

but didnt get good result. I tried for the last few days and was unsuccessful and as I am not a software expert but defnintely learning and curious how to set this up. Thanks!!!

> App\Composer::configure
Database setup
- DB_CONNECTION (mysql):
- DB_HOST (127.0.0.1):
- DB_PORT (3306):
- DB_DATABASE (laravel):
- DB_USERNAME (root):
- DB_PASSWORD:
Mail setup
- MAIL_MAILER (smtp):
- MAIL_HOST (smtp.mailtrap.io):
- MAIL_PORT (2525):
- MAIL_USERNAME ():
- MAIL_ENCRYPTION ():
- MAIL_PASSWORD:
> @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 = laravel and table_name = migrations and table_type = 'BASE TABLE')

at C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop\vendor\laravel\framework\src\Illuminate\Database\Connection.php:742
738▕ // If an exception occurs when attempting to run a query, we'll format the error
739▕ // message to include the bindings with SQL, which will make this exception a
740▕ // lot more helpful to the developer instead of just the database's errors.
741▕ catch (Exception $e) {
➜ 742▕ throw new QueryException(
743▕ $query, $this->prepareBindings($bindings), $e
744▕ );
745▕ }
746▕ }

1 C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop\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:\Users\ADMIN\Desktop\SoftwareIndependent\myshop\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "aimeosaimeos", [])
Script @php artisan migrate handling the post-create-project-cmd event returned with error code 1

C:\Users\ADMIN\Desktop\SoftwareIndependent>

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by aimeos » 03 Jun 2022, 18:42

You have to create a database in your MySQL server first and then enter the correct database, user and password when the setup script is asking for.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

chaoslucifer
Posts: 7
Joined: 03 Jun 2022, 17:50

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by chaoslucifer » 03 Jun 2022, 19:09

Thanks you your team are really quick to response

I created a few database but not sure if i link it correctly:
PHPMyAdmin.PNG
PHPMyAdmin.PNG (89 KiB) Viewed 20185 times
and i change my .env to the following:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myshop
DB_USERNAME=root
DB_PASSWORD=xxxx

and did the following:
php artisan migrate:fresh

but still give the error:

Illuminate\Database\QueryException

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')

at C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop\vendor\laravel\framework\src\Illuminate\Database\Connection.php:742
738▕ // If an exception occurs when attempting to run a query, we'll format the error
739▕ // message to include the bindings with SQL, which will make this exception a
740▕ // lot more helpful to the developer instead of just the database's errors.
741▕ catch (Exception $e) {
➜ 742▕ throw new QueryException(
743▕ $query, $this->prepareBindings($bindings), $e
744▕ );
745▕ }
746▕ }

1 C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop\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:\Users\ADMIN\Desktop\SoftwareIndependent\myshop\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=mysql", "root", "aimeos", [])

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by aimeos » 03 Jun 2022, 19:16

Create a new user/password that is allowed to connect to the server. Use the "mysql" command at the command line to test if the user/password combinations works when connecting to "localhost".
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

chaoslucifer
Posts: 7
Joined: 03 Jun 2022, 17:50

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by chaoslucifer » 03 Jun 2022, 19:45

I see thanks!!! It seem like mysql is not working:

When running it in windows command line:

Code: Select all

C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop>mysql -h 127.0.0.1 -u root -p aimeos
'mysql' is not recognized as an internal or external command,
operable program or batch file.
I used XAMPP will that cause issues? As XAMPP is running my sql database right now. And I don't think windows command line realized that or pick it up and let me use "mysql" in the cmd probably why i am getting that error.
XAMPP.PNG
XAMPP.PNG (40.03 KiB) Viewed 20184 times
I just tried the following and it fail:

Code: Select all

C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop>pip install mysql
Collecting mysql
  Downloading mysql-0.0.3-py3-none-any.whl (1.2 kB)
Collecting mysqlclient
  Downloading mysqlclient-2.1.0-cp310-cp310-win_amd64.whl (180 kB)
     ---------------------------------------- 180.3/180.3 kB 1.5 MB/s eta 0:00:00
Installing collected packages: mysqlclient, mysql
Successfully installed mysql-0.0.3 mysqlclient-2.1.0
WARNING: There was an error checking the latest version of pip.

C:\Users\ADMIN\Desktop\SoftwareIndependent\myshop>mysql -h 127.0.0.1 -u root -p aimeos
'mysql' is not recognized as an internal or external command,
operable program or batch file.
I assume I have to go install mysql as followed:
How to Install MySQL on Windows10? | MySQL Tutorial for Beginners | MySQL Training
FYI in case someone needs this in the future:
https://www.youtube.com/watch?v=GIRcpjg-3Eg

Thanks!

chaoslucifer
Posts: 7
Joined: 03 Jun 2022, 17:50

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by chaoslucifer » 03 Jun 2022, 20:01

Any suggestion about those errors or am i moving in the right track by getting mysql installed?

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by aimeos » 06 Jun 2022, 06:37

The "mysql" command is not necessary to be available. It was only a suggestion how you can test if the connection to the server works from the command line.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

chaoslucifer
Posts: 7
Joined: 03 Jun 2022, 17:50

Re: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'

Post by chaoslucifer » 07 Jun 2022, 09:15

For those who needs it in the future.

Ok it seem like i didn't realized inputs i need for this portion so i needed to go back and change this based on what myphpadmin was telling me and the video provide the best example but it wasn't clear on the server setup but now everything is resolved.
https://www.youtube.com/watch?v=0FUEfM_divg

Portion in needed to fix in CMD.

Code: Select all

- DB_CONNECTION (mysql):
- DB_HOST (127.0.0.1):
- DB_PORT (3306):
- DB_DATABASE (laravel):
- DB_USERNAME (root):
- DB_PASSWORD:

Post Reply