Install PHPMyAdmin from script installs improperly configured PHPMyAdmin that can't run SQL queries (403 error)

SYSTEM INFORMATION
OS type and version Debian 12
Webmin version 2.105
Virtualmin version 7.9.0
Related packages PHPMyAdmin

Since installing PHPMyAdmin from the script offered in VirtualMin GPL, I can mostly use it, but unfortunately I need to run SQL queries in it using the features it provides to do that, and every time I do, instead of results I get a popup saying:

Error in processing request
Error code: 403
Error text: Forbidden (rejected)
It seems that the connection to server has been lost. Please check your network connectivity and server status.

In the apache log I see lines such as:

 "POST /phpmyadmin/index.php?route=/lint HTTP/2.0" 403 17224 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:109.0) Gecko/20100101 Firefox/115.0"

But that’s all I get, and nothing turns up in the Apache or PHP error logs. I don’t have any idea why it’s returning a 403 error. All configuration was done via VirtualMin’s script and all sit configuration has been done via VirtualMin from the start.

I’ve found numerous posts around the internet referring to a Log feature in PHPMyAdmin which apparently has been completely removed in the latest version, and to a myPhpAdmin.conf file that apparently new versions don’t use and a thorough hard drive search shows does not exist on my server.

Right now I’m trying to find a single row of a huge table that is causing me problems and I need to delete it. Having to do this by clicking, scrolling, and eyeballing thousands of rows, without being able to use a SQL query, is a major pain point. I need to be able to run queries on my database tables.

It would be better for VirtualMin to not offer scripts than to offer scripts that leave you with broken installs that then create hours of troubleshooting. This has so far consumed an entire day trying to find a solution myself prior to posting here. It would have been better if I had just known from the beginning that it was not possible, or, if I had not been led to believe VirtualMin would allow me to install a working PHPMyAdmin, and instead just installed PHPMyAdmin manually, as I have done in the past with no problems like this whatsoever.

maybe it a php setting. Can you export the database ok or does that error. How big are the queries. I’ve moved databases no problems.

Thanks for your reply.

I have no problem at all exporting the database.

It does this for all queries, big or small. For instance, it just did it for SELECT * FROM wpnf_options ORDER BY option_name DESC where I am sure the table and field names are correct.

EDIT: Wait. Strangely, SELECT * FROM wpnf_options works. Nothing else does. I can’t use WHERE or ORDER BY or anything like that. Why would some queries be fine, but then adding an ORDER BY creates a 403 connection error?

Incidentally, I tried turning off firewalld and fail2ban and it didn’t help. I also don’t have anything I can see or that I don’t understand in my .htaccess file.

I’m not a sql person, cut and paste sort of guy. Can you test the queries via command line?
The error is weird, maybe its a timeout waiting for a response.

The same queries run fine from the command line, the only problem is doing them from PHPMyAdmin. In fact, simple queries that work from within WebMin’s MariaDB module fail with a 403 in PHPMyAdmin from the same browser session. VirtualMin’s scripted PHPMyAdmin install is clearly broken or misconfigured. (I’m not enough of a SQL person either to figure out how to find and remove the row I need from the command line, and WebMin’s module doesn’t offer the query type I need. All instructions online specify to use PHPMyAdmin.)

The error message is not just instantaneous, it doesn’t seem like a timeout.

Virtualmin just installed the latest version (hopefully). Its not doing anything different then if you installed yourself. I guess you have tried uninstalled and reinstalled?

Maybe try via webmin

Yeah, tried that. Also tried the LTS version, which spit up a LOT more errors, it was virtually unusable, so I uninstalled that and reinstalled the latest.

I just can’t believe there’s no log anywhere that will tell me why the server is giving a 403 error. All I need to see is the reason so I can fix it. But all it tells me is that it did.

Re: running the query from webmin…

Hey, look at that! They sure do tuck that little “Execute SQL” button away where you’re not likely to see it, I even looked for it and didn’t notice it.

Yeah, queries are working from within Webmin’s “Execute SQL”, so that’s a workaround. Still not so happy, though, as PHPMyAdmin has niceties like autocomplete and generally would be much easier and less error-prone than doing it this way, especially as there are braindead-precise instructions for PHPMyAdmin (when PHPMyAdmin works) and not for doing it through Webmin, but, it does work, so, thanks for pointing that out!

The perfectionist geek in me reeeeeeeeeeally wants PHPMyAdmin to work right, though. Even if I can get my work done, unsolved mysteries bother me. They just do.

Got me, someone else might have a clue. Maybe its a OS thing.

Who knows. I’m on a totally stock install from Live ISO of Debian 12 except for WebMin/VirtualMin, so it seems like if there was a platform issue I’d be able to find info somewhere… I think it’s a pretty common setup. It’s a headscratcher.

I’m not going to mark this as solved because I still want to see if anyone can help get PHPMyAdmin working, but thanks for at least getting me to where I could take care of what I needed to and move on to something else.

Do you have mod_security enabled? Furthermore, you should check Apache error_log, not access log.

I have found the VirtualMin Edit Database panel (either thru a specific VM server or from Webmin – Servers – MariaDB Database Server, choose a db) to be very adequate for my purposes – hence I never got around to installing PHPMyAdmin.

… your mileage may vary :grinning:

Adequate (but a little clunky) phpMyAdmin is a well honed product based on many years of use and does just about everthing in one place - horses for courses.

Do you have mod_security enabled? Furthermore, you should check Apache error_log, not access log.

Thanks. Mod_security isn’t enabled. There was nothing in error_log about it at all.

I have found the VirtualMin Edit Database panel (either thru a specific VM server or from Webmin – Servers – MariaDB Database Server, choose a db) to be very adequate for my purposes

Yeah, it would seem so, thanks to the help I received above I eventually managed to get done what I needed to. But often online there are precise instructions for doing things in PHPmyAdmin, right down to which button to click (or, I should say, “often online there were precise instructions right down to which button to click until PHPmyAdmin recently apparently completely changed the logging features and totally obsoleted at least a decade’s worth of Stack Overflow answers”, but, that’s a different issue.) Anyway, I find that wading around in Linux administration, an area I’m not 100% comfortable with, getting precise directions vs getting “close enough” directions can often mean the difference between getting something done in 2 minutes vs spending a day and a half lost down a research rabbit hole of not-quite-100%-right documentation and Q&A forums. So I prefer to use PHPmyAdmin if possible, just because of the ubiquity of answers saying to use it.

Honestly if everyone online would just say how to do things using the mysql CLI that would be good enough for me. But, no, everybody likes PHPmyAdmin. Teach a man to fish, he’ll eat for a lifetime. But slap a point-and-click interface on a fishing rod, and he’ll go out and tell everyone else to use it.

Back with the install error:

when you load phpMyAdmin and go to the home page is it showing all the correct info for the Database Server, (MariaDb), Webserver and phpMyAdmin versions? Also check that the plugins have been loaded
if you cannot see the sql button
sql button
it may be a plugin not loaded. (I think the plugins are on separate GPL installs)

Yep, all that looks correct. And I can see the Sql button, the problem is, the second I type in a query, before I even hit “Go”, I get a 403 error popup, for any query with a where or other clause after the table name. For instance, in this image, SELECT * FROM wpnf_options works fine, SELECT * FROM wpnf_options WHERE 1 (or WHERE [anything]) gives the error.

It sure looks like some sort of permissions error. But I can’t find anything anywhere that explains it, just the one line in the access log saying that it did in fact happen (not the error log, there’s no entry in there about it at all). There’s nothing in any .htaccess or .conf file I’ve been able to find that might explain it.

If the connection has been lost that sounds like a fault with the setup of the MariaDB I wonder if that is another of those OOM killer issues that @Joe has been discussing elsewhere?

You got me. I did the setup through Webmin/Virtualmin so I would hope it’s correct. I’m running a couple of Wordpress installs off of it and have seen no other sign of a database error or misconfiguration. Also the same query does work fine from within Webmin’s own Execute Query function, so I’m not sure how it could be an OOM problem with just MariaDB.