docker
docker copied to clipboard
Add support for creating internal DB "phpmyadmin" via ENV value
When using this image, I'm getting this warning message, when logged into PMA:
The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated
It should be nice to add the creation of this DB automatically, probably using some ENV variable.
Agreed! The idea of using docker is to make it automatic and repeatable.
But this problem means there is a manual step in every deployment...
I'm trying to find a workaround using the config file, but haven't managed so far. If someone has a workaround please post here.
I found a workaround - define it in the config.user.inc.php
file:
$i = 1;
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['users'] = 'pma__users';
But this is still not perfect, because on first run it still shows the error. But then you can click on "create missing tables" and then it works.
Any plans to fix? It could be great if we didn't need to click on the 'create missing tables' on the first run.
I have an idea, creating a command to run that would fill the database and create it using the configuration
@mauriciofauth do you have opinions about this idea ?
I think the argument could be made either way, about whether this should be done by the user in their own set up or should be done automatically in the official image.
I'm not sure we should go about automatically creating the database, because (in general) we try not to do anything to manipulate outside programs/images. Even though adding the phpMyAdmin database or controluser is not destructive, it might not be desired. So would creating it be the default behavior, or an optional flag that could be added.
As an implementation detail, creating the controluser might be a little tough because the SQL commands vary between older MySQL, newer MySQL, and MariaDB versions. We'll need to get the MySQL user credentials for an existing superuser, is that something we can do reliably in the Docker universe?
My gut says (if we can get correct permissions from the user)that we should allow creating this through passing an ENV variable, but not make it the default. Creating the user is a few lines of SQL and then sourcing the create_tables script should be pretty trivial. But again, I'm concerned about making changes to other images/software and think any implementation of this would have to be considerate of those concerns.
For my .0002 -- opting in via an ENV makes the most sense (i actually that that was already the case with the PMA_PMADB variable)
My gut says (if we can get correct permissions from the user)that we should allow creating this through passing an ENV variable, but not make it the default. Creating the user is a few lines of SQL and then sourcing the create_tables script should be pretty trivial. But again, I'm concerned about making changes to other images/software and think any implementation of this would have to be considerate of those concerns.
I agree about that, by default nothing is done.
If the ENV for example PMA_PMADB_AUTO_INSTALL=1
is set then we use the ENVs to connect and if it is successful then we execute the SQL file to create the tables