502 Bad Gateway after strapi switch database

You most likely didn’t grant the user you created permissions on the database.

create database someName;
create user someUser@localhost identified by 'somePass';
grant all privileges on someName.* to someUser@localhost;