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

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.

Then there must be a difference between the two WP apps.

The one that works OK and the one that doesn’t

You have ruled out Webmin/Virtualmin and the script as presumably you have used the same scripts for both VS to install both WP and phpMyAdmin

There is no WP app that doesn’t work ok. My WP installs work fine, there is no sign of any error in any of them.

My problem is with queries in PHPMyAdmin, which is running on the MariaDB instance that all my WP sites use. The errors are only happening directly in PHPMyAdmin.

I get the same error

Ive found one virtual server phpMyadmin queries works fine so now I’m real confused.

Found the issue on my server, its was Wordfense, its was blocking the queries. Once I deactivated it the queries worked.

1 Like

Why am I not in the least surprised, a WordPress plugin yet again!

It is rarely WordPress itself (though they could do a better job of policing their plugins & themes) it is nearly always the poor programming of the plugins at fault.

It could be as simple as closing a connection that was not “owned” by the plugin.

Actually the plugin is doing its job, its detecting what could be hacking of the database. A false positive I guess.
I added my ip to the whitelist and works fine now, hopefully its the issue for OP.

You wanna hear something a little frustrating? The problem went away by itself.

I just tried again and all queries are working from within PHPMyAdmin, including the one I screenshotted above as showing an error. I haven’t changed anything since I took that screenshot. I have no idea what’s up.

I do use wordfence, so I thought it might be the same error, but I haven’t turned wordfence off yet, and as you can see in this screenshot, the exact same query now returns results, not an error:

Weird. Nice from a user perspective, not so nice from an admin perspective… if I don’t know what the problem was, I don’t know if or how long the mysterious “self-fix” will last.

I would hazard a guess that it’s not something wrong with the install script, then, since if that was the case it probably wouldn’t be a sporadic problem like this.

I’m going to leave this open for a while, maybe someone has some idea, or in case the problem comes right back again, or if anyone has any suggestions of other places to look for logs giving the 403 error reasons when they do happen, as that would be nice to know. Thanks to all commenters for taking an interest!

Pretty sure it’s Wordfence, add your ip in the whitelist to stop any future issues.

Wordfence may be involved, but it can’t just be Wordfence, because I had Wordfence on both then and now, and haven’t reconfigured it (or reconfigured anything at all), and I got the error then but aren’t… amn’t… er… ain’t getting it now. There’s got to be some other factor involved.

If it happens again, though, I’ll try turning WF off and report back. For the moment I’m not going to add my local network IP (I access all this over the local LAN) to Wordfence because then if it doesn’t happen again I won’t know if adding my IP to Wordfence actually helped or if it just happened not to happen again. I made that mistake a few years ago, when someone told me a good way to keep alligators away, and it did work, I haven’t seen an alligator. But ever since then I’ve walked around with a banana stuck in my ear, I’m afraid to take it out.

In wordfence I saw my IP being blocked, thats why I’m pretty sure effecting my queries.

And the award goes to @stefan1959 , who was right to be persistent about it being Wordfence. It was Wordfence.

I don’t know why it’s not blocking me today, but here’s Wordfence’s log from 3 days ago, when I captured the first error screenshot, saying it was “blocked by firewall for SQL Injection in POST body: sql_query=SELECT%20*%20FROM%20%60wpnf_options%60%20WHERE%201

This also answers the question of where there would be a log entry explaining the 403 if Apache’s error log didn’t have it. Here it is. Mental note: Remember to check Wordfence AND Apache’s logs next time.

Both mysteries solved. Thanks for your help!

1 Like

BTW, just for the record:

Virtualmin just installed the latest version (hopefully). Its not doing anything different then if you installed yourself

It is apparently different if you install via a script. According to everything I can find on the internet, PHPMyAdmin is supposed to have a phpmyadmin.conf file, or a phpmyadmin/apache.conf file, or a /etc/phpmyadmin/ folder containing a .conf file, or an /etc/httpd/ subfolder of some sort containing a .conf file related to PHPMyAdmin.

I can’t find any such thing anywhere on my install, and according to Phpmyadmin conf file for virtualmin/webmin, others haven’t been able to either and concluded that it doesn’t exist in the installation you get via virtualmin.

Not sure what doc you finding that. P.S. Ok the forum.

https://docs.phpmyadmin.net/en/latest/config.html

Config file is config.inc.php and its in the install directory.
I think everything is in the virtual servers phpmyadmin folder.
And I think a manual install would do the same thing.

Yes, that’s PHPMyAdmin’s .php config file, which sets internal variables used in PHP by the script.

I’m talking about the .conf file that contains apache directives related to PHPMyAdmin, referred to on these pages:

As I haven’t installed it myself in many years other than through this script, I don’t know firsthand, but they, and many others I saw, all say it should be there, which the other Virtualmin discussion I linked before https://forum.virtualmin.com/t/phpmyadmin-conf-file-for-virtualmin-webmin/107388/4 agrees with and says it looks like Virtualmin doesn’t install PHPMyAdmin the usual way.

Right, I just had a look in github, the script is there if you wanna try and work out what they do.
As long as it works I’m happy.

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