new MySQL user not working through SSH
We have just upgraded to a VPS plan in order to get Magento 2.4 fully working (it requires elasticsearch, which needed the VPS and which I've already installed; that's unrelated to my problem though).
I've just added a new MySQL database through cPanel, and added a user for it, which is of course listed as associated with the database.
When I go into the Root WHM panel's Terminal and try to connect to MySQL through commandline for that user, it works fine.
Example command (replaced actual username with "test_db_user"):
mysql -u test_db_user -p
It connects with that user account fine.
However, when I connect through SSH as my standard CPanel user and run the same command, giving the same password,I get:
ERROR 1045 (28000): Access denied for user 'test_db_user'@'localhost' (using password: YES)
After checking through various things, I then added privileges for an existing MySQL user to the new database. I again can connect fine through the root terminal to the older username, and running "show databases;" lists the older database that user already had access to along with the new database which I just added privileges for. No problems there.
I then connect again through SSH as my standard CPanel user and try to connect to MySQL while specifying that older MySQL user. This time it connects properly, no error. However, when I run "show databases;", it only lists the old database that MySQL user already had access to; it doesn't list the new database, even though the new database showed up through the same command through the root terminal.
It's like it's seeing an older cached version of the MySQL databases (or maybe just MySQL users) when I try to connect through my standard account through SSH. I've tried restarting the MySQL service and restarting the VPS itself, no change in behavior.
Why would this be happening? How can I fix it? Will it just fix itself given enough time? I need to be able to run the installer for Magento 2.4 through SSH which naturally requires database access, so I need to find a fix. The only workaround I can think of is to co-opt an older existing database and user, just wiping that database, but I'd rather not have to resort to that.