3

I want to do some MySQL-specific testing and need to run a fresh MySQL database as non-root user. I am using Debian Linux and expect one could start the mysql_install_db and other commands as normal user with the right options and writable locations.

  1. Does this work?

  2. How to do it?

I don't want to download software from the MySQL website. Instead I want to use the executables provided by the already installed OS packages. The reasoning is this:

  1. The software is already installed--installing new software from the net is pointless, slow, might fail, possibly a security risk etc. To my knowledge KDE is doing something similar for its data storage.

  2. If it does eventually work I want to wrap the test in a portable script that runs on any computer where mysql_install_db etc. are available.

I searched the web for tutorials/hints but only found loads of descriptions on how to install the software from scratch. With information from what I had read I then tried this:

mkdir ~/tmp/mysql/
mkdir ~/tmp/mysql/mysql/
mkdir ~/tmp/mysql/sql_data/

mysql_install_db \
    --defaults-file=my.cnf
    --user=daniel
    --basedir=/home/daniel/tmp/mysql/mysql/
    --datadir=/home/daniel/tmp/mysql/sql_data/
    --socket=/home/daniel/tmp/mysql/socket

But it complains:

FATAL ERROR: Could not find my_print_defaults

The following directories were searched:

   /home/daniel/tmp/mysql/mysql//bin
   /home/daniel/tmp/mysql/mysql//extra

UPDATE: I still didn't find a solution to limiting the output to error messages. I get many lines with the tag [Note] but didn't find an argument to set debug output level.

3

1 Answer 1

1

I found similar calls in the Akonadi code and started to build the commands from scratch while consulting the respective help texts. It looks like I just included useless/counterproductive options before. This did now work for me:

mysql_install_db                    \
  --defaults-file=/dev/null         \ # don't user my.cnf in /etc/ or ~/
  --datadir=/home/daniel/tmp/mysql/ \ # use given directory for data
  --force                             # make mysqld work without /usr/bin/resolveip

I seem to need only 1 directory for data. Setting basedir only works if you provide a complete MySQL installation.

After this I could run the MySQL server:

mysqld                              \
  --defaults-file=/dev/null         \ # as above
  --datadir=/home/daniel/tmp/mysql/ \ # as above
  --socket=/home/daniel/tmp/socket  \ # use writable socket
  --skip-networking                   # for my purposes: only socket connections

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .