0

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)

Command:

php bin/magento setup:install --base-url="http://127.0.0.1/m243" --db-host="localhost" --db-name="m243" --db-user="root" --db-password="test@!123" --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --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.

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

5 Answers 5

1

If the password contains any special characters, then we need to escape them by adding a backslash before the special characters. Below is an example using the password test@!123. This will help resolve the "Access denied" problem when you have already attempted to use valid credentials but they are not working.

--db-password="test\@!123"
1
  • thank you its working Commented May 16 at 10:44
0

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

0

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=http://127.0.0.1/magento2/ \
--db-host=localhost 
--db-name=magento 
--db-user=magento 
--db-password=magento \
--admin-firstname=Magento
--admin-lastname=User 
[email protected] \
--admin-user=admin 
--admin-password=admin123 
--language=en_US \
--currency=USD 
--timezone=America/Chicago 
--use-rewrites=1 \
--search-engine=elasticsearch7 
--elasticsearch-host=es-host.example.com \
--elasticsearch-port=9200
0
  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.

0

if you have created a virtual host..try this command:

php bin/magento setup:install --base-url="http://127.0.0.1/m243" --db-host="127.0.0.1" --db-name="m243" --db-user="root" --db-password="test@!123" --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --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"

if you haven't created a virtual host and running it locally your base url would be changed..try below command for localhost:

php bin/magento setup:install --base-url="http://127.0.0.1/m243/pub" --db-host="127.0.0.1" --db-name="m243" --db-user="root" --db-password="test@!123" --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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