mysqlmariadbmariadb-10.5

can I instruct mariadb-install-db and mariadb to ignore 'user' setting in config?


If I want to set up a mariadb a database and start mariadb as a local user:

I can easily override parameters such as --datadir=$HOME/mariadb/data or --error_log=$HOME/mariadb/log/mysql_error.log,
but I didn't find a straightforward way to have mariadb-install-db or mysqld to ignore the user = mysql setting that is set up in my system configuration files.

I'm running mariadb 10.5 on a ubuntu system, with standard system config files located in /etc/mysql/.

Note that this isn't really a blocking point, because I get warnings and both the install and the mysqld daemon apply their actions succesfully. It makes for scary warnings though:

$ mariadb-install-db --user=legec --datadir=$HOME/mariadb/data
chown: cannot access '/usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool': Permission denied
chown: changing ownership of '/usr/lib/mysql/plugin/auth_pam_tool_dir': Operation not permitted
2023-12-14 17:51:57 0 [Warning] Ignoring user change to 'legec' because the user was set to 'mysql' earlier on the command line
2023-12-14 17:51:57 0 [Warning] Ignoring user change to 'legec' because the user was set to 'mysql' earlier on the command line
...

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

$ echo $?
0

On my system, the user = mysql setting is provided in file /etc/mysql/mariadb.conf.d/50-server.cnf,
if I remove that line and remove the --user=legec option from cli, the warning goes away.

Question

Is there a way to instruct mysqld and mariadb-install-db to run as local user and completely ignore any user setting ?
or override an option to state "I want to run as current user, ignore any user setting" ?


Solution

  • The straight forward way is to use --no-defaults.

    mariadb-install-db --no-defaults  --datadir=$HOME/mariadb/data
    

    With no --user setting it will use the current user as the installation user and not try to chown the auth_pam_tool helper.

    --no-defaults, like all the --default* command line options must occur first in the command line.


    To preserve existing settings:

    my_print_defaults --mysqld | grep -Ev -- '--(user|datadir)' |
      xargs mariadb-install-db --no-defaults --datadir=$HOME/mariadb/data