#1 2025-12-14 22:45:41

BobbyV
Member
Wales
2007-04-22
73

Help needed with mySQL permissions

Hi,
I need to understand permissions to help me fix an issue.
I believe I have the correct permissions on the files and folders; they are all owned by www-data, which is in the www-data group. As a temporary measure, I even changed the permissions to 777 on everything but it didn't help.

Whilst trying to fix another issue, I dropped the plugins table and had to manually rebuild it with phpMyAdmin.
When I try to add any plugin, while it shows up in the "List/Deactivated" tab, it fails to add a record to this table and therefore will not activate.

BUT if I use phpMyAdmin, logged in with the same credentials I use in Piwigo, I can manually insert a record for the new plugin in that table, and it all activates and works just fine.

I have done this with three plugins, all three activate and work, so obviously going in with phpMyAdmin can add to the plugins table, whilst Piwigo can not.
I could probably carry on manually, but I have about 25 plugins to add, and I would rather understand and fix the issue.

So, my question is, when I log in to Piwigo (same credentials), why can't Piwigo add those records?

Environment:
Piwigo 16.1.0
Installed on July 8, 2023, 2 years 5 months 6 days ago
Operating system: Linux
PHP: 8.3.6 (Show info) [2025-12-14 21:34:02]
MySQL: 8.0.44-0ubuntu0.24.04.2 [2025-12-14 21:34:02]
Graphics Library: External ImageMagick 6.9.12-98
Cache size 13181.86 Mo   calculated 3 hours ago
Activated plugin list 3
meta
Meta Open Graph
Miro

Piwigo URL: https://photos.g4xca.uk/

Offline

 

#2 2025-12-15 08:30:33

polowigo
Member
France
2022-08-06
45

Re: Help needed with mySQL permissions

Hi,

The only thing I think about it is that your database user has not privileges enough on the table you have manually rebuid.
If it's true, you may try :
GRANT ALL PRIVILEGES ON your-database.the-plugins-table TO 'the-database-user'@'localhost' IDENTIFIED BY 'the-password';
FLUSH PRIVILEGES;
Considering the /local/config/database.inc.php file settings.

I hope that works.

Offline

 

#3 2025-12-15 19:05:16

BobbyV
Member
Wales
2007-04-22
73

Re: Help needed with mySQL permissions

Many thanks for your reply Polowigo, it makes perfect sense.

I'm not good with SSH/command lines etc so I logged into phpMyAdmin over the network and ran those commands in the SQL tab as follows:
GRANT ALL PRIVILEGES ON piwigo-db.piwigo-plugins TO 'myusername'@'localhost' IDENTIFIED BY '============';
But I got a syntax error referring to "near 'IDENTIFIED BY '============'.
So I ran it again without the IDENTIFIED BY '============' and didn't get any reported errors this time.

I then ran FLUSH PRIVILEGES; and got no errors:
But sadly everything was the same :-(

After more Googling, I used these commands, but still no joy
GRANT ALL PRIVILEGES ON piwigo_db.* TO 'myusername'@'localhost';
FLUSH PRIVILEGES;
and even these
GRANT ALL PRIVILEGES ON *.* TO 'myusername'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'myusername'@'theIPaddress';
myusername was copied from the local/config/database.inc.php file so should be right.
Mystery eh?

Offline

 

#4 2025-12-15 19:28:30

polowigo
Member
France
2022-08-06
45

Re: Help needed with mySQL permissions

Mystery indeed, where is Sherlock ?
Have you experienced other trouble apart plugins? With installing themes, manage albums?...

Offline

 

#5 2025-12-15 20:04:42

BobbyV
Member
Wales
2007-04-22
73

Re: Help needed with mySQL permissions

polowigo wrote:

Have you experienced other trouble apart plugins? With installing themes, manage albums?...

No, everything is working well, I've just tested by adding a new theme, adding a new album and uploading photos.
Everything is perfect except plugins.
The whole site has been superb for over 2 years but I did update from 15.6 back in October but can't be sure when this issue started.

So that I understand correctly, the credentials stored in the /local/config/database.inc.php file are used by piwigo to talk to the database and nothing else? There is no need to add a piwigo user of that name, I just have me and I am webmaster.
www-data is used by piwigo to own and access the various folders (I have 777 now, just for testing)

If I back up the database, delete it, and rebuild with the saved .sql file, will it still have all the same permissions and privileges as before? I won't be better off?

Offline

 

#6 2025-12-15 22:12:56

polowigo
Member
France
2022-08-06
45

Re: Help needed with mySQL permissions

The database.inc.php file is dedicated to the database precisely. Here is an extract :
$conf['dblayer'] = 'mysqli'; (cou'd be maysql possibly I think)
$conf['db_base'] = 'the_database_name';
$conf['db_user'] = 'the_database_user'; (for me, different from the administrator account and personal account too)
$conf['db_password'] = 'the_database_password'; (the password used by the database user)
$conf['db_host'] = 'localhost';

About the folders, they need usually www-data(www-data) 755

I can't reliably answer to your last question.

Sorry to not be of any help.

Offline

 

#7 2025-12-16 02:42:04

moberley
Member
2025-11-10
90

Re: Help needed with mySQL permissions

On my server Piwigo does not automatically add the plugin to the plugins table in the database when installing through the "add a new plugin" tab. It only does so the first time the activate action is invoked.

Upon reading through the relevant code it appears that when the activate action is processed, and the plugin only appears in the plugins folder and not the plugins table, then Piwigo invokes the install action for that plugin.

This calls the specific plugin's install function and if that produces no errors then it inserts the plugin into the plugins table. Then it calls the plugin's activate function and if that produces no errors then it updates the plugins table to show the plugin is active.

If you are manually updating the plugins table then some plugins might not work when they depend on some action in their install or activate functions. I'm not sure if those functions are called in some other way.

If plugins aren't appearing in the plugins table when you try to activate them then I think that is for some other reason that is happening before Piwigo tries to add the plugin to the table.

Last edited by moberley (2025-12-16 02:55:27)

Offline

 

#8 2025-12-16 12:04:31

BobbyV
Member
Wales
2007-04-22
73

Re: Help needed with mySQL permissions

moberley wrote:

This calls the specific plugin's install function and if that produces no errors then it inserts the plugin into the plugins table...
...If plugins aren't appearing in the plugins table when you try to activate them then I think that is for some other reason that is happening before Piwigo tries to add the plugin to the table.

Fantastic, thanks for this. So it may not be a permissions issue.
Yes, when I try to add a plugin, it creates a folder, and populates it, in the "plugins" folder.
That folder and files have these permissions (I chmoded to 777 for testing) -rwxrwxrwx 1 www-data www-data
Then when I try to activate, it errors.

I'm not skilled in PHP, so can you check if there are any calls to log the error and, if so, where I can read those logs? It might give me a clue.

Thanks, Bob

Offline

 

#9 2025-12-16 22:00:18

moberley
Member
2025-11-10
90

Re: Help needed with mySQL permissions

From the web interface the activation switch makes a request to the Piwigo web service API so I think you might be able to see the errors in the browser.

Before trying to activate a plugin open up the developer tools (should be available as "Inspect" in the menu after right clicking on the plugins page) and open the "Network" tab. After you click the activation switch you should see a request to something like:

/ws.php?method=pwg.plugins.performAction&action=activate&plugin=user_custom_fields&pwg_token=xxxxxxxxxxxxxxx&format=json

And if you select that you should see a response tab that will show you some JSON data coming back from Piwigo. When there are errors you should see some information in that data.

Offline

 

#10 2025-12-17 09:51:44

BobbyV
Member
Wales
2007-04-22
73

Re: Help needed with mySQL permissions

I did that and the response tab says this, but it's beyond me now :-(

<b>Fatal error</b>:  Uncaught mysqli_sql_exception: Field 'name' doesn't have a default value in /var/www/html/piwigo/include/dblayer/functions_mysqli.inc.php:132
Stack trace:
#0 /var/www/html/piwigo/include/dblayer/functions_mysqli.inc.php(132): mysqli-&gt;query()
#1 /var/www/html/piwigo/admin/include/plugins.class.php(148): pwg_query()
#2 /var/www/html/piwigo/admin/include/plugins.class.php(191): plugins-&gt;perform_action()
#3 /var/www/html/piwigo/include/ws_functions/pwg.extensions.php(76): plugins-&gt;perform_action()
#4 /var/www/html/piwigo/include/ws_core.inc.php(605): ws_plugins_performAction()
#5 /var/www/html/piwigo/include/ws_protocols/rest_handler.php(41): PwgServer-&gt;invoke()
#6 /var/www/html/piwigo/include/ws_core.inc.php(281): PwgRestRequestHandler-&gt;handleRequest()
#7 /var/www/html/piwigo/ws.php(22): PwgServer-&gt;run()
#8 {main}

Offline

 

#11 2025-12-17 19:20:47

moberley
Member
2025-11-10
90

Re: Help needed with mySQL permissions

That error appears to be in response to Piwigo's attempt to "INSERT INTO" the plugins table. If that is correct then MySQL is complaining because it is trying to process the INSERT but Piwigo sends only the plugin 'id' and 'version' and, for some reason your MySQL database is expecting to receive a value for 'name'.

The "Field 'name' doesn't have a default value" error means MySQL is trying to add a row without being provided a value for 'name' but 'name' has no DEFAULT set in the table structure so that query fails.

You said you had to rebuild the plugins table using phpMyAdmin so maybe double check the the structure of your plugins table to see if there is a 'name' column? Based on what I have that table should only have the following columns (each with a DEFAULT value):

Code:

`id`      varchar(64)               NOT NULL DEFAULT ''
`state`   enum('inactive','active') NOT NULL DEFAULT 'inactive'
`version` varchar(64)               NOT NULL DEFAULT '0'

When I export from phpMyAdmin here is the CREATE TABLE I receive on my server (Piwigo 16.1.0).

Code:

CREATE TABLE `piwigo_plugins` (
  `id` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '',
  `state` enum('inactive','active') NOT NULL DEFAULT 'inactive',
  `version` varchar(64) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_uca1400_ai_ci;

Offline

 

#12 2025-12-17 21:35:31

BobbyV
Member
Wales
2007-04-22
73

Re: Help needed with mySQL permissions

moberley wrote:

Code:

CREATE TABLE `piwigo_plugins` (
  `id` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '',
  `state` enum('inactive','active') NOT NULL DEFAULT 'inactive',
  `version` varchar(64) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_uca1400_ai_ci;

Fantastic, I think you've solved it. I dropped the table and ran your SQL. I had to delete the CHARATER SET, COLLATE and ENGINE bits, but it then built the table without errors.

I've installed and activated a few plugins and all looks OK.

I have to pop out tonight, but I will fully test this tomorrow and report back.
I can't thank you enough. I had no idea about the developer's tools/network/response. This is certainly going to help in the future. Best regards Bob.

Offline

 

#13 2025-12-18 01:09:55

moberley
Member
2025-11-10
90

Re: Help needed with mySQL permissions

Glad to hear your Piwigo is working better.

Offline

 

#14 2025-12-19 02:07:19

BobbyV
Member
Wales
2007-04-22
73

Re: Help needed with mySQL permissions

After a full day of testing, I'm very pleased to say that everything is working great now, and I've learned a lot of new things.
So thanks to both of you, your help and advice has been invaluable.
Bob in Wales.

Offline

 

Board footer

Powered by FluxBB