I installed Magento 2.4.3 in ubuntu, but when I run the below command it gave me errors like,

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)


php bin/magento setup:install --base-url="" --db-host="localhost" --db-name="m243" --db-user="root" --db-password="test@!123" --admin-firstname="admin" --admin-lastname="admin" --admin-email="admin@gmail.com" --admin-user="admin" --admin-password="admin@123" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --search-engine="elasticsearch7" --elasticsearch-host="localhost" --elasticsearch-port="9200"

but when I login into PHPMyAdmin using the same id password of the database

user name: root, password: test@!123

it was worked but did not work in the terminal when I run the command.

please help me with this.

  • Confirm that Magento install directory is named m243 and it's not just your database name ?
    – Claims
    Oct 11 '21 at 13:57

Try the host as and not localhost as technically they are different


If the database is created and the issue still persists then try the command like this i.e. without the quotes ".

bin/magento setup:install --base-url= \
--db-password=magento \
--admin-email=user@example.com \
--language=en_US \
--use-rewrites=1 \
--elasticsearch-host=es-host.example.com \
  1. Log in to the MariaDB/MySQL shell using the mysql command below.

mysql -u root -p

Now create a new database for Magento installation. Create the database 'magentodbatabase' and the user 'magentodatabaseuser' with the password 'magentodbpassword'.

  1. Run the MySQL queries below.

    create database magentodbatabase;

    create user magentodatabaseuser@'localhost' identified by 'magentodbpassword';

    grant all privileges on magentodbatabase.* to magentodatabaseuser@'localhost';

    flush privileges;

  2. Now type 'exit' to log out from the MySQL shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.