reggie86
reggie86

Reputation: 289

MySQL will not start after relocating to external hard drive RPi

I am attempting to relocate a MySQL database from my Raspberry Pi to my external hard drive so that I can keep a larger database. I know very little about this, so I apologize if this question is too simple, but these are the steps I have taken so far, as suggested on an RPi forum:

$ sudo /etc/init.d/mysql stop
$ sudo mkdir /path/to/new/datadir
$ sudo cp -R /var/lib/mysql/mysql /path/to/new/datadir
$ sudo nano /etc/mysql/my.cnf
datadir = /path/to/new/datadir
$ sudo chown -R mysql:mysql /path/to/new/datadir
$ sudo /etc/init.d/mysql start

Unfortunately, now I am getting an error when attempting to execute the last line (as shown above):

$ sudo /etc/init.d/mysql start

When I attempt to execute that last line, I get the following message:

[...] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed.
See 'systemctl status mysql.service' and 'journalctl -xn' for details. failed!

I checked journalctl -xn and was told: No journal files were found.

systemctl status mysql.service yielded the following error:

mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql)
Active: failed(Result: exit-code) since Sun 2017-02-26 22:15:08 ET; 4 min 4 sec ago
Process: 12923 ExecStop=/etc/init.d.mysql stop (code=exited, status=0/SUCCESS)
Process: 14171 ExecStart=/etc/init.d.mysql start (code=exited, status=1/FAILURE)

Additional information: my filepath which I moved the active directory has a space in it, which is not enclosed by quotation marks. If I do put quotation marks around it, I fail at Process 13627 instead.

Let me know if you have any suggestions-- thanks!

Upvotes: 0

Views: 447

Answers (2)

Robert Sim
Robert Sim

Reputation: 194

check for ownership of the copied datadir folder. make sure that it is owned by mysql user and group.

command to use:

ls -lah /path/to/copieddir

it should read something like this:

drwxr-xr-x  7 mysql mysql 4.0K Mar  8 15:28 .
drwxr-xr-x 50 root  root  4.0K Jan 20 14:50 ..
drwx------  2 mysql mysql 4.0K Nov  1 15:36 mysql
drwx------  2 mysql mysql 4.0K Nov  1 15:36 performance_schema

if you are seeing something this:

drwxr-xr-x  7 user user 4.0K Mar  8 15:28 .
drwxr-xr-x 50 root  root  4.0K Jan 20 14:50 ..
drwx------  2 user user 4.0K Nov  1 15:36 mysql
drwx------  2 user user 4.0K Nov  1 15:36 performance_schema

run this command:

sudo chown -R mysql:mysql /path/to/copieddir

Upvotes: 1

yaquaholic
yaquaholic

Reputation: 152

Use ls with the long switch (-l) to show file/folder permissions:

ls -l /path/to/new/

Try 'man ls' for more details on the ls command and some further reading for you, chmod and or chown will also be of interest.

Oh and Unix file permissions - https://en.wikipedia.org/wiki/File_system_permissions#Notation_of_traditional_Unix_permissions

Upvotes: 0

Related Questions