Elderry
Elderry

Reputation: 2072

Fail to move mysql's data directory

I'm trying to move the data directory of mysql, here are my steps:

Result:

mysqld.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
   Active: activating (start-post) (Result: exit-code) since Tue 2013-07-30 14:31:53 CST; 13s ago
  Process: 14174 ExecStart=/usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Control: 14175 (mysqld-post)
   CGroup: name=systemd:/system/mysqld.service
           └─control
             ├─14175 /bin/sh /usr/bin/mysqld-post
             └─14293 sleep 1

Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [Warning] Can't create test file /home/elderry/db/Kanone.lower-test
Jul 30 14:31:53 Kanone mysqld[14174]: [71B blob data]
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [ERROR] Aborting
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [Note] /usr/bin/mysqld: Shutdown complete
Jul 30 14:31:53 Kanone systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE

What shoud I do for now?

Upvotes: 1

Views: 3272

Answers (3)

Daishi
Daishi

Reputation: 14289

Also check if your partition is not full, which was my case.

For an unknown reason, moving the data to another partition did not work either.

So for a quick fix, instead of messing with llvm or gparted, I reduced my /swapfile size.

Upvotes: 0

Igor Fil
Igor Fil

Reputation: 212

When installing MariaDB, it creates user and group mysql automatically that own all data files, so if you move data dir, make sure that all folder, subfoler, files in new data directory are owned by user mysql and group mysql.

Upvotes: 0

Flo Doe
Flo Doe

Reputation: 5381

It seems you moved the datadir to your home directory. I think that when you start mysqld via your service manager (in your case systemd) it will be started as an unprivileged user (most likely mysql). I strongly doubt that this user has privileges to access the homedir of the user elderry.

So the solution would either be moving your datadir to a more suitable location like /var/lib/mysql and chown this directory to the user under which mysql runs. Or that you give the mysql user privileges that he can acces the homedir of elderry.

Upvotes: 1

Related Questions