Access denied for user ‘root’@‘localhost’

At step bench new-site site1.local getting the following error,

pymysql.err.OperationalError: (1045, u"Access denied for user ‘root’@‘localhost’ (using password: YES)")
seems to have highlighted in multiple threads…no progress

Any help would be appretiated

mysql -uroot -pYourMysqlPasswordOfChoice -Bse "GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.%.%.%' IDENTIFIED BY 'YourMysqlPasswordOfChoice' WITH GRANT OPTION;"
mysql -uroot -pYourMysqlPasswordOfChoice -Bse "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'YourMysqlPasswordOfChoice' WITH GRANT OPTION;"

Thanks for the response

Reinstalled mysql from instruction from the mariadb home page…the current problem is as follows

raise Exception(“Database %s already exists” % (db_name,))
Exception: Database _1bd3e0294da19198 already exists

On the server side the following happens

2019-06-04 13:24:36 10 [Warning] Aborted connection 10 to db: ‘unconnected’ user: ‘root’ host: ‘localhost’ (Got an error reading communication packets)

Delete the existing database, or specify a different db name on bench new-site:

% bench new-site --help                                                                                                                                                             
Usage: bench  new-site [OPTIONS] SITE

  Create a new site

  --db-name TEXT                Database name
  --mariadb-root-username TEXT  Root username for MariaDB
  --mariadb-root-password TEXT  Root password for MariaDB
  --admin-password TEXT         Administrator password for new site
  --verbose                     Verbose
  --force                       Force restore if site/database already exists
  --source_sql TEXT             Initiate database with a SQL file
  --install-app TEXT            Install app after installation
  --help                        Show this message and exit.

Thanks ,

I am following the instructions at this link…

Would this is complete to bring up the erpnext system

In my understanding, you stuck in first site creation and in some way you already tried before and the “old” db still there.
So, in this case, you already have the same db name that bench new-site is going to create, if you don’t delete the old db or you don’t specify a new name, you can’t proceed.

Hope this can help you

I tried this command:
Now I am getting this error:

For key innodb_large_prefix. Expected value ON, found value OFF
For key collation_server. Expected value utf8mb4_unicode_ci, found value utf8mb4_general_ci
For key innodb_file_format. Expected value Barracuda, found value Antelope
Creation of your site - erp.LTS failed because MariaDB is not properly
configured.  If using version 10.2.x or earlier, make sure you use the
the Barracuda storage engine.

Please verify the settings above in MariaDB's my.cnf.  Restart MariaDB.  And
then run `bench new-site erp.LTS` again.

Database settings do not match expected values; stopping database setup.

could you please help me

Edit your mysql config file…
nano /etc/mysql/my.cnf
and make sure it includes something like this…

character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
# Set buffer pool size to 50-80% of your computer's memory
# Set the log file size to about 25% of the buffer pool size
# the default here is 4MB, or maybe 16MB?? in more recent versions, which sometimes allows for disconnects in the middle of transactions

default-character-set = utf8mb4

Then restart mysql
sudo systemctl restart mysql
and then try to run the bench new-site erp.LTS again

I faced a similar issue on Mac. Following the steps mentioned here solved my issue - Install MariaDB with brew on macOS and fix the “access denied” issue · GitHub

In summary to fix it (with MariaDB still running):

  1. sudo mysql then enter your Mac user password
  2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'newrootpassword'; replacing newrootpassword with the password you wish to use for the MariaDB root user.
  3. Ctrl-C to exit mysql.

You should then be able to connect to MariaDB with mysql -u root -p, then entering the root password when prompted.

1 Like

Thank You, This solution worked for me!