Page 1 of 1

[SOLVED] How to save MariaDB's databases?

PostPosted: Mar 12th, '14, 05:53
by FiableDotBiz
Hello.

Our hard disk, with Mageia 3, got a bad block problem. We can still read it, but not boot on it. I installed this disk as secondary disk (on another computer working with Fedora 20 Gnome). I would like to save the databases (containing Drupal websites) of the old disk, so I installed mariadb and phpmyadmin packages on a new booting hard disk with Mageia 4, set up the same password as for the old disk (I don't know where MariaDB password is stored), copied the configuration file /etc/my.cnf and the folder /var/lib/mysql to the new disk. But mysqld refuses to start. I get
Code: Select all
# systemctl status mysqld.service
mysqld.service - MySQL database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: failed (Result: start-limit) since Wed 2014-03-12 18:08:35 ULAT; 2s ago
  Process: 20618 ExecStartPost=/usr/sbin/mysqld-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 20245 ExecStart=/usr/bin/mysqld_safe --nowatch (code=exited, status=0/SUCCESS)
  Process: 20228 ExecStartPre=/usr/sbin/mysqld-prepare-db-dir (code=exited, status=0/SUCCESS)
 Main PID: 20617 (code=exited, status=1/FAILURE)

Mar 12 18:08:35 Dell-graphist systemd[1]: Failed to start MySQL database server.
Mar 12 18:08:35 Dell-graphist systemd[1]: Unit mysqld.service entered failed state.
Mar 12 18:08:35 Dell-graphist systemd[1]: mysqld.service holdoff time over, scheduling restart.
Mar 12 18:08:35 Dell-graphist systemd[1]: Stopping MySQL database server...
Mar 12 18:08:35 Dell-graphist systemd[1]: Starting MySQL database server...
Mar 12 18:08:35 Dell-graphist systemd[1]: mysqld.service start request repeated too quickly, refusing to start.
Mar 12 18:08:35 Dell-graphist systemd[1]: Failed to start MySQL database server.
Mar 12 18:08:35 Dell-graphist systemd[1]: Unit mysqld.service entered failed state.


Or is it better, in my Fedora computer, to configure MariaDB to read the old disk databases and to produce a .sql file? If so, how to configure MariaDB for this ?

Thank you if you can help.

Re: How to save MariaDB's databases ?

PostPosted: Mar 13th, '14, 09:04
by alien
mariadb (and mysql) have an error log file which can tell you what went wrong...

it should be at /var/log/mysql.err or similar. ( my.cnf should contain the exact filename in the log-error directive )

that said, it is much easier if you got a .sql file instead.

boot with 2nd disk, mount disk partitions from 1st disk in some location, and do a "mysqldump -p drupal > drupal.sql" (or whatever the database is called).

that file can then be imported after creating an empty database into an existing running server.

echo 'CREATE DATABASE drupal' | mysql -p
mysql -p drupal < drupal.sql

Re: How to save MariaDB's databases ?

PostPosted: Mar 14th, '14, 12:59
by FiableDotBiz
Thank you very much. I eventually succeeded by the 1st method (copying file /etc/my.cnf and folder /var/lib/mysql to the new disk). The problem was an ownership problem: all MariaDB files should belong to the user "mysql".

The second method (producing .sql files directly from the mounted old disk) didn't work, because I don't know how to direct mysqldump to the databases: the mounted old disk is not the standard location.

I've also begun writting this page: https://wiki.mageia.org/en/MariaDB