@Telos
back to the basics:
502 Error or bat Gateway Error means:
the web server you’ve connected to is acting as a proxy for relaying information from another server, but it has gotten a bad response from that other server. It’s called a 502 error because that’s the HTTP status code that the webserver uses to describe that kind of error.
Is this your problem (visualised on the screenshot below)?
-------------------------------------------------------
Reproduction of your problem:
1. Scenario:
- DB is down (container stopped)
Login causes an Internal Error ..... this isn't your case:
-------------------------------------------------------
2. Scenario:
- wrong NPM DB/Schema admin user/psw
No relevant user found or Invalid psw ..... this isn't your case.
-------------------------------------------------------
3. Scenario:
- changed psw for NPM Schema Admin = user based on the NPM docker-compose
or
- changed user's host value from "%" to "localhost"
where:
- DB_MYSQL_USER is the Schema Admin, and its psw is defined by DB_MYSQL_PASSWORD
- both are stored in NPM config.json - path: mounted volume defined in the docker-compose ... in your case: ./data
Result:
It was also confirmed by the lost communication from tcpdump between NPM container and DB container.
After repairing the psw or the host value - everything was OK.
-------------------------------------------------------
Workaround:
So, based on your last MariaDB checklist uploaded and a lot of scary deployments, you need open SSH in your DB:
(deployed docker-compose is needed for copy-paste steps)
A. renew the DB_MYSQL_USER grant to other than localhost use (one side of your problem):
change host from 'localhost' to 'any host' by '%'
Bash:
RENAME USER 'telos'@'localhost' TO 'telos'@'%';
then
just to be sure:
B. renew the DB_MYSQL_USER password defined by docker compose in DB_MYSQL_PASSWORD
Bash:
SET PASSWORD FOR 'telos'@'%' = PASSWORD('password');
then
Bash:
ALTER USER 'telos'@'%' PASSWORD EXPIRE NEVER;
then
Set a grant for 'npm' Schema to 'telos'@'%'. Note - you need to use the same Schema name as is in your docker-compose DB_MYSQL_NAME. When the value = "npm", then:
Bash:
GRANT ALL ON npm.* TO 'telos'@'%';
then
Check the NPM config.json if you can find the same Usr/Psw there. When not - replace them.
Restart both containers - NPM and MariaDB.
Done
Log into your NPM.
-------------------------------------------------------
At the end>:
Just to be sure - my first consideration was about tracking lost communication (502 Error = Bad Gateway). In a similar case, I anytime need to see tcpdump. When the default Docker bridge network is used:
Bash:
tcpdump -i docker0 src <IP_NPM> -w '/path/nmp_tcpdump.pcap'
# example:
# tcpdump -i docker0 src 172.0.20.25 -w '/volume1/docker/nmp_tcpdump.pcap
where:
IP_NPM is IP Address defined by Docker/Bridge network for the NPM:
Bash:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 'container ID or Name'
# example
# docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 17755e72ee05
container ID or name you can get from:
Then the nmp_tcpdump.pcap file is possible to investigate by WireShark. What helped me to 100% confirm the 502 Error = Bad Gateway.
[automerge]1653312092[/automerge]
Just last point
what is the difference between Schema and Database:
This tutorial teaches you about Schema and Database, and the key differences between them. It also highlights what the schema and database are in MySQL and Oracle.
www.delftstack.com
very, very simply described:
SQL DB engine, e.g. MySQL, MariaDB, PostgreSQL, .... is a complex environment for storing, managing, securing, ... of data
Database: deployed SQL DB engine
Schema: one instance (called also database) within the Database.
Then in a single Database, you can run many Schemas (NPM, ...) with many different users/privileges for the Schemas.
You can define which user is able to connect to the database from which host (localhost, defined IP, wildcard, ...).
When you don't have the correct setup within the Schema, you can't connect the Schema and you can receive finally also Bad Gateway in your Front end.
[automerge]1653312560[/automerge]
Btw, all the setup for Users and privileges is possible w/o a single CLI code, while you will use more useful tool like mentioned SQL Workbench.
I prepare each new SQL/Schema deployment in advance, including a clear set of user/host rights, which I would otherwise click on through the CLI for a long time.
Include the Backup/Restore procedure.
[automerge]1653312875[/automerge]
There's another handy tool that even runs from a USB stick - no need to install it. Unfortunately only for Win OS.
HeidiSQL is a free and powerful client for MariaDB, MySQL, Microsoft SQL Server, PostgreSQL, SQLite and Interbase/Firebird
www.heidisql.com
is much easier than Workbench. Ideal for fast user/host management and simple management tasks. However, it has the great advantage of supporting all SQL DBs directly.