pymysql.err.OperationalError when creating a new app and site

Installed frappe, erpnext using frappe-docker as per its instructions in dev mode
Everythingwas fine and coudl access the site
Went going thorugh the tutorial - create a new app and new site.
Create the library management app to understand teh frappe framework
Was able to login initially when it was created but once I restarted today got this error:

pymysql.err.OperationalError

pymysql.err.OperationalError: (1045, “Access denied for user ‘_ad03fa1a016ca1c4’@‘172.19.0.3’ (using password: YES)”)

Traceback (most recent call last)

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/app.py”, line 54 , in application

init_request(request)

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/app.py”, line 125 , in init_request

frappe.local.http_request = frappe.auth.HTTPRequest()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/auth.py”, line 34 , in __init__

self.set_session()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/auth.py”, line 71 , in set_session

frappe.local.login_manager = LoginManager()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/auth.py”, line 124 , in __init__

self.make_session(resume=True)

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/auth.py”, line 201 , in make_session

full_name=self.full_name, user_type=self.user_type)

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py”, line 194 , in __init__

self.resume()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py”, line 255 , in resume

data = self.get_session_record()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py”, line 273 , in get_session_record

r = self.get_session_data()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py”, line 289 , in get_session_data

data = self.get_session_data_from_db()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py”, line 311 , in get_session_data_from_db

self.device = frappe.db.sql(‘SELECT device FROM tabSessions WHERE sid=%s’, self.sid)

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py”, line 122 , in sql

self.connect()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py”, line 75 , in connect

self._conn = self.get_connection()

  • File “/workspace/development/frappe-bench/apps/frappe/frappe/database/mariadb/database.py”, line 90 , in get_connection

local_infile = frappe.conf.local_infile)

  • File “/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/init.py”, line 94 , in Connect

return Connection(*args, **kwargs)

  • File “/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 325 , in __init__

self.connect()

  • File “/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 599 , in connect

self._request_authentication()

  • File “/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 861 , in _request_authentication

auth_packet = self._read_packet()

  • File “/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 684 , in _read_packet

Tried some solutions posted:
site_config looks fine with a user, password and DB (I guess it sis encrypted)
$ bench --site library.test mariadb
ERROR 1045 (28000): Access denied for user ‘_ad03fa1a016ca1c4’@‘172.19.0.3’ (using password: YES)
$mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)

Not sure why the system tries to conect to 172.19.0.3
Did some reading - but the file above does not exist ‘/run/mysqld/mysqld.sock’ (2)’ at the path

Does anyone know the solution?
Installing a site creates a DB. Is it created incorrectly? Did not try anything fancy. Just followed the tutorial of frappe.

update: I dropped the site using bench drop-site and recreated it
The change I did this time was - during the first login as Administrator, the setup wizard asks for a ‘Your First User’. Specifying the user here never works.
The user you specify is not created with the right privileges and the whole installation breaks with errors related to db as given above. This is the 3rd time,I have faced this - first in erpnext installtion. It also gives errors like the user does not have access to DocType.
This is definitely a bug in startup wizard. I am not sure why that screen is provided. You login as administrator and then specifying the ‘first user’ makes the whole system go belly-up. The solution that has worked for me everytime is to specify the ‘Administrator’ as the first user. Use ‘Administrator’ as user, email and specify the same password that you set for Adminstrator. This does not corrupt the DB. Probably later you can add the user through the desk though I haven’t yet tried it .
I am not sure if frappe-framework is stable but it is cerainly flaky. Here I did not try anything fancy - just followed the tutorial everystep and ended up with weird DB errors which take you down a path of removing db, reinstallting, etc. The actual error is the setup wizard itself.

That’s UNIX socket.
What do you get with: ps xa | grep mysqld
Maybe you should try on Debian 10 or 11 installation, I solved installation problems with this tutorial: [Tutorial] How to 'manually' install ERPNext v13.11 Production on Debian 10 (w/SSL cert)

thanks @why, will follow your tutorial. I did manage to install but after a long struggle.
One question - which user did you create during the startup wizard - ‘Your first user’ . Did you create any random user. I have consistently faced issues at this step - for 3 different installations. It worked for me only when I specified ‘Administrator’ as my first user. The system breaks and you get all kinds of privilege errors or mysql errors after specifying a random first user.
None of the installation guide cover this and it takes you downwrong paths of reinstalling mysq, etc

I didn’t used Administrator as first registered user.
Yes, tutorials don’t cover errors during installation.