Granting permissions to mysql users

SYSTEM INFORMATION
OS type and version Debian 10
Virtualmin version 7.7

Hello All

First time poster here.

Almost a year ago, I set up this server and migrated several sites from my old cPanel server.

Most of everything went relatively smoothly, but I have had no mySQL functionality whatsoever. Every few weeks, I try to get it working, but since it is not a revenue generating site, I give up after a few hours and go back to more important things.

Today I was finally able to ascertain that there are no permissions granted to any of the users for any of the databases on any of the sites that I migrated from cPanel. I have now spent hours trying to figure out how to grant those permissions.

Help!?

Brian

DB is my weakest ‘skill’. But, webmin > Servers > ( I have ) Maria Database Server > User Permissions

EDIT: Or use scripts to install php MyAdmin.

You can also check in Virtualmin Tab: drop down to domain in question:
Edit Users > click on the user that needs permissions
Other user permissions > highlight the database and click on the arrow → Granted access to
Save

Okay. These two processes have already been tried.

First, cyberndt: That shows that the user in question has access to all databases under that account (domain).

ID10T: When I go there, the user (in fact, all users for all accounts, except root) shows ‘no permissions’, but when I click on the user, there is a box with what permissions to grant. No matter what I select in that box, nothing gets granted. I would have expected it to be similar to the other page where there are two boxes and arrows to select and deselect, but there isn’t.

I have been at those two pages over and over while trying to get this working, but nothing seems to work the way it is supposed to.

Also, I have been trying to install phpmyadmin serverwide, but I can get it installed on only one domain. (Do I have to install it separately on each domain on the system?) If I could get it installed so that I could log in as root, I might get somewhere. (It cannot be installed on the domain that I am currently working on due to another issue. But, of course, I am hoping to solve this issue on all domains.)

Thanks

Brian

Only thing I can think of:

In Webmin > Servers > Maria/MySQL whatever you have? Go to Database Permissions.

See if the Database with the main-user/user for the account is listed with ALL Permissions.

If not? Then click on the ones needed and highlight to Grant ALL.

Yes. On that page, all users are listed with “All permissions” granted each to its respective database.

Everything I have tried since day one appears to be set correctly, but when I log into mysql from the command prompt and “SHOW GRANTS”, I get nothing at all. Only root is granted any permissions. I think that I can figure out how to grant permissions through the cli, but for dozens of users and databases that will take a lifetime of typing.

Am I correct in believing that SHOW GRANTS should show all grants for all users? Or should it show only those permissions granted to root?

Thanks again.

Brian

SHOW GRANTS would be for the user logged into mysql>

SHOW GRANTS FOR <username>@<host>;

Would give a particular user.

So I was mistaken that there were no permissions granted to the other users. Good to know.

It seems that all grants are there as they should be, but if I select the user from the user table (in the main mysql db), all permissions are set to ‘N’, except for the user to whom I granted all permissions (from the cli).

I created a short php script (while in ssh as root) to connect using those credentials and it connected fine. But the page on the site won’t connect even though I seem to have granted privileges akin to root.

I’m not sure if maybe I’m barking up the wrong tree.

Thanks

Brian

Are you using the correct format for the username and database in the config?

You have mentioned that this came over from a cpanel server. I believe their username and database names are in different format from what Virtualmin uses.

So far, I have been testing using mysqli_connect(‘localhost’, ‘username’, ‘password’) and doing a var_dump of the result. On the web page, I am simply getting bool(false), while in the script run as root from the cli (exactly the same credentials), I am getting an object where all seems right.

Could it be the difference between running as root vs www?

I haven’t yet even made it to actually trying to run queries on any tables.

Thanks

Brian

Update:

I have sort of been barking up the wrong tree insofar as it’s not permissions but passwords which are giving me the issue.

I have been able to get the following error out of my db:
“PHP Warning: mysqli_connect(): (HY000/1275): Server is running in --secure-auth mode, but ‘user’@‘localhost’ has a password in the old format; please change the password to the new format in /home/pathto/script.php on line x”

The thing is all my passwords are in the ‘new’ format (which I think was new almost ten years ago). All of my searching has revealed that the old format had a 16 character hash and the new one 41 characters. All of mine have 41 characters.

So when I run the (portion of the) script in question, I get the above error, both on the command line and in the browser. (Actually, the browser doesn’t show the error, just the result.) But when I run the exact same code (with the same credentials) in the new script I wrote as root, it connects with no error.

Also, if I simply change the credentials in the original script to the root user, it also connects flawlessly.

Edited to add: So I guess this isn’t really a virtualmin issue, but I’m grateful for help in any case.

Thanks

Brian

1 Like

Have you tried to reset the user password within Virtualmin?

Hi Brian

I am facing a similar SQL privs issue.

My problem is that my SQL server is on a different server to the virtualmin server. Therefore the DB users need the remote login permission.

Have you tried an explicit grant to the user on the sql server?

try
GRANT ALL PRIVILEGES ON yourDB.* TO user1@‘133.155.44.103’ IDENTIFIED BY ‘userspassword’;

Yes. I had tried both of those solutions. It turns out that it is a Virtualmin problem after all.

I tried also to change the password for the account itself, Virtualmin warning me that that would change the mySQL password. That didn’t work.

However, I have since made a discovery (from a 4 year old post on Virtualmin’s old forum) that the queries I was running on the mysql database, while appearing to have an effect, did not indeed have any effect.

Instead of UPDATE mysql.user SET Password = PASSWORD(‘mypassword’) WHERE
, the way to do it (and it seems to need to be done with every imported db) is set password for user@localhost = PASSWORD(‘mypassword’). Once I used that syntax, everything worked.

Thanks for all your help.

Brian

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.