mysql-server-5.7 fails to install on box with separate /var/lib/mysql partition

Bug #1580794 reported by Adrian Bridgett
30
This bug affects 5 people
Affects Status Importance Assigned to Milestone
mysql-5.7 (Ubuntu)
Triaged
Medium
Lars Tangvald

Bug Description

the postinst has a line that checks to see if there is a database installed by doing "ls -A" on the state directory (/var/lib/mysql). If you have this as a separate filesystem you are likely to have a lost+found directory here. The postinst then doesn't setup the new DB correctly and the install fails.

I'm not sure why there's an ls here, rather then for example checking for a "mysql" database directory?

Revision history for this message
Robie Basak (racb) wrote :

Thanks, we should fix this. Separately from this though I'd recommend creating a directory inside your filesystem and using that, because we have /var/lib/mysql-keyring and /var/lib/mysql-files now and you probably want those in that filesystem too.

Changed in mysql-5.7 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Adrian Bridgett (adrian-bridgett) wrote :

Ah cool, thanks for the tip Robie!

Revision history for this message
Lars Tangvald (lars-tangvald) wrote :

It's a limitation of the --initialize option used to create the database that it's very picky about what can be in datadir. It will ignore anything starting with a ., but for anything else it will fail (unless specified with --ignore-db-dir).
That's the reason we assume that if there's anything in datadir we shouldn't run database initialization.

Robie Basak (racb)
tags: added: mysql-alternate-datadir
Changed in mysql-5.7 (Ubuntu):
milestone: none → ubuntu-16.09
Changed in mysql-5.7 (Ubuntu):
assignee: nobody → Lars Tangvald (lars-tangvald)
Revision history for this message
Daniel Black (daniel-black) wrote :

ignore_db_dirs=lost+found by default maybe?

Revision history for this message
Lars Tangvald (lars-tangvald) wrote :

Part of the problem is that any directory inside datadir will be treated as a schema, which could produce some pretty odd results in this case.
While changing mysqld --initialize to ignore this directory would fix the failure and be safe, to avoid having it be read as a schema we'd need to add the same to the default server config, which I'm a bit more reluctant to do, though granted it's not very likely that people will want a schema named lost+found :)
As a first step we could add a check to detect the situation (since it does seem to be a fairly common use case), and add a warning explaining the issue.

Revision history for this message
Daniel Black (daniel-black) wrote :

sounds root regarding mysqld --initialize.

slightly laxer option for
mountpoint -q ${datadir} && cp my.lost_found.cnf /etc/mysql/cnf.d/....

to be really prudent you could see if lost+found is empty or contains only whatever filename extX "recovers" files to.

Robie Basak (racb)
tags: added: triage
Revision history for this message
Rafael (rvallel) wrote :

I have arrived to this issue as I have trouble installing mysql with data on a Logical Volume.

Traditionally I would just mount a Logical Volume on /var/lib/mysql prior to installing mysql-server. That would setup the database from the start on the volume.

I am reading this thread and I see that there are now 3 directories with data, plus trying to avoid lost+found.

What is the process for installing mysql-server with another data filesystem/volume?

is it possible to create a config file prior to installing mysql-server so that it will get installed using the new filesystem?

What should the process be?

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Unfortunately, we do not have a doc explaining how to achieve that. I am also not aware of a way to "preseed" the mysql-server package to do what you want. What you could try to do in order to avoid lost+found is to make use of a symlink, for instance mount it into /mysql and then create a symlink from /var/lib/mysql to /mysql/data.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.