0

I'm packaging a small system that uses mysql as a database. The system is made in PHP and uses Symfony as a framework.

When installing the system I need to create the database, user and popular.

The package has all dependencies, including mariadb-server and dbconfig-mysql.

Tried to follow the tutorial dbconfig-common, and this is my DEBIAN/config

set -e
. /usr/share/debconf/confmodule

if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
    . /usr/share/dbconfig-common/dpkg/config.mysql
    dbc_go kaya-rest "$@"
fi

php /etc/nerd4ever/kaya/back-end/bin/console doctrine:migration:migrate -q

I also have it in my archive package: /usr/share/dbconfig-common/data/kaya-rest/install/mysql (created after reading other examples)

CREATE DATABASE IF NOT EXISTS kaya;
CREATE USER IF NOT EXISTS 'kaya'@'localhost' IDENTIFIED BY '<my_password>';
GRANT ALL PRIVILEGES ON kaya.* TO 'kaya'@'localhost';
FLUSH PRIVILEGES;

I expected that at the end of the installation the database, user and password had been created and the doctrine migrations had populated the database, none of this happened and the installation does not show any error message.

The mysql status at the end of the installation is stopped. At no point during the installation of my package do I start the database.

Sileno Brito
  • 449
  • 1
  • 13
  • 31

1 Answers1

0

While not starting the MySQL server, the SQL will never run. CREATE DATABASE might require the MySQL root password. Putting this into a post-install script might be unfortunate, because these scripts are not really meant to accept any input.

Better just put a setup.sh in the installation directory, which one can run.

Most of the database setup in PHP applications is GUI based.

Braiam
  • 1
  • 11
  • 47
  • 78
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • but isn't that totally against the dbconfig-common proposal? I remember having already used a script to update the database (no create), but I wanted to improve it. – Sileno Brito Aug 20 '21 at 11:40