Reputation: 23
I want to safe the Databases on an Usbstick and not on my RaspberryPi.
First I did:
service mysql stop
mkdir /media/pi/EMTEC/mysql
nano /etc/mysql/my.cnf and changed datadir=/media/pi/EMTEC/mysql
cp -Rv /var/lib/mysql/* /media/usb4/mysql/
chown -R mysql:mysql /media/usb4/mysql/
which worked without problems
My my.cnf:
[client-server]
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
datadir=/media/pi/EMTEC/mysql
When trying to restart the mysql service I receive:
mysql: unknown variable 'datadir=/media/pi/EMTEC/mysql'
How do I fix that error?
Upvotes: 1
Views: 7462
Reputation: 1
The above solution didn't solve my problem.
I did move the datadir under [mysqld] but it was giving errors for other files, so I moved all below files under [mysqld].
like below and it fixed issues at my end.
[mysqld]
datadir=/var/lib/mysql
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Upvotes: 0
Reputation: 1815
Add datadir
to [mysqld]
section. datadir
is a global variable to configure mysql server.
[mysqld]
datadir=/your/new/dir/
Upvotes: 2