Error: OperationalError: (1045, “Access denied for user ‘erpnext’@‘localhost’ (using password: YES)”)
Solution: In this KB, I will elaborate you to how this error can be solved with simple steps.
Setup your remote database (DB) to accept remote connections easily
-
Edit MariaDB configuration file to accept remote connections by changing its bind-address from 127.0.0.1 to 0.0.0.0 If this entry is not available you may add new line in given below file.
Path: sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Value to be add in the file: bind-address = 0.0.0.0 -
Login to your MySQL and create a database user (Not new user, the same user can be added with new host) so that Frappe will use to authenticate.
CREATE USER ‘root’@‘[IP ADDRESS FOR ERPNext YOUR NEW HOST]’ IDENTIFIED BY ‘[YOUR PASSWORD OF CHOICE OR PASSWORD STORED IN YOUR site-config.json FILE]’;
Ex. create user ‘xyzuser’@‘172.16.1.10’ identified by ‘admin@erpnext’; -
Grant the created root user permissions to make changes to the created databases.
GRANT ALL PRIVILEGES ON . TO ‘root’@‘[IP ADDRESS FOR ERPNext YOUR NEW HOST]’ IDENTIFIED BY ‘YOUR PASSWORD OF CHOICE’ WITH GRANT OPTION;
Ex. grant all privileges on . to ‘xyzuser’@‘172.16.1.10’ identified by ‘admin@erpnext’; -
Flush the privileges to effect changes to the database and log out from MySQL.
FLUSH PRIVILEGES;
then
EXIT; -
Restart MySQL server to effect all the made changes.
sudo service mysql restart -
Test the connection using the below command:
mysql -u root -h [IP ADDRESS FOR DATABASE HOST] -p -
If the request still not working, you may need to ensure that there is no firewall that blocks connections to TCP port 3306 of the MySQL server. We use the below command to allow an IP address on your servers:
ufw allow from [IP ADDRESS FOR ERPNext HOST] to any port 3306
There is no other problem, you have to use the same credentials stored in site-config.json file for the DB user for new host connection only.