# Mysql restart after server reboot is giving an error when using systemd

**URL:** https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179
**Category:** Percona XtraBackup
**Created:** [June 23, 2024, 8:55pm UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179 "2024-06-23T20:55:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ipcmlr](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ipcmlr](https://forums.percona.com/u/ipcmlr)
#### Post date: [June 23, 2024, 8:55pm UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179/1 "2024-06-23T20:55:55Z")

</div>

After a reboot mysql doesnt start.  
Looking at the errorlogs I see " --initialize specified but the data directory has files in it. Aborting."  
which obviously means that it is trying to start with --initialize after a reboot.  
I asked our sysadmin to run “systemctl unset-environment MYSQLD\_OPTS” just in case something strange happened (this is after an os upgrade).  
It is still giving me the same error.  
What else should I look at?  
Starting up the service manually like sudo service mysql start doesnt give any errors.  
thanks.

---

<div class="post-metadata">

### Author: ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)
#### Post date: [June 24, 2024, 1:58am UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179/2 "2024-06-24T01:58:42Z")

</div>

It sounds like mysql _is_ starting on boot, but, as you discovered it’s trying to initialize. Can you confirm the OS and MySQL version please?

---

<div class="post-metadata">

### Author: ![ipcmlr](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ipcmlr](https://forums.percona.com/u/ipcmlr)
#### Post date: [June 24, 2024, 3:24pm UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179/3 "2024-06-24T15:24:38Z")

</div>

OS is oracle linux 8 and mysql version is 8.0.21-12 Percona Server

---

<div class="post-metadata">

### Author: ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)
#### Post date: [June 24, 2024, 7:06pm UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179/4 "2024-06-24T19:06:38Z")

</div>

Do you have the mysql data dir mounted from NFS or other sharing service? If so, it may be that the mount is not mounted when the system boots and thus it fails, but when you do it manually, it has mounted and it’s fine.

---

<div class="post-metadata">

### Author: ![ipcmlr](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@ipcmlr](https://forums.percona.com/u/ipcmlr)
#### Post date: [June 25, 2024, 11:55am UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179/5 "2024-06-25T11:55:30Z")

</div>

Yes it is nfs.  
Let me check with the sysadmin.  
What do you suggest when using NFS to avoid the issue of it not mounting before the service starts?  
thanks

---

<div class="post-metadata">

### Author: ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)
#### Post date: [June 25, 2024, 5:52pm UTC](https://forums.percona.com/t/mysql-restart-after-server-reboot-is-giving-an-error-when-using-systemd/31179/6 "2024-06-25T17:52:32Z")

</div>

Your sysadmin can modify the unit file for mysql to have it depend on nfs mounts. That way nfs will mount before mysql starts.
