# Mysql\_install\_db issues

**URL:** https://forums.percona.com/t/mysql-install-db-issues/15313
**Category:** MySQL & MariaDB
**Created:** [April 20, 2022, 3:25pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313 "2022-04-20T15:25:46Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)
#### Post date: [April 20, 2022, 3:25pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/1 "2022-04-20T15:25:46Z")

</div>

PLEASE HELP OUT!!  
I used this statement $ mysql\_install\_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql on an existing server with Datadir inside another directory.

Now I can’t see my Database , I can’t log in again. I tried reversing it by specifying my path to my directory but I got an error like this

“installation of system table failed examine the log in ‘/log/mariadb/mariadb.log’ or /data2 for more information , the problem could be a conflicting information inside an external my.cnf files you can ignore it by doing: /bin/mysql\_install\_db —defaults=~/.my.cnf”.

I have all my databases in /data2 directory and my users but Mysqld is using /var/lib/mysql as directory like I said earlier. I have done all I can. Also I know for sure Mysqld is picking up another configuration file from another place. I don’t know. Because all my variables are different now

---

<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: [April 20, 2022, 5:03pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/2 "2022-04-20T17:03:47Z")

</div>

Why did you run mysql\_install\_db when you already had an existing datadir? The default config is /etc/my.cnf but also look for /etc/mysql/

---

<div class="post-metadata">

### Author: ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)
#### Post date: [April 20, 2022, 5:08pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/3 "2022-04-20T17:08:29Z")

</div>

Because I received any error. Failed so I thought that could resolve it. Any possible solution to this

---

<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: [April 20, 2022, 5:10pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/4 "2022-04-20T17:10:25Z")

</div>

The solution is to remove /var/lib/mysql and fix your my.cnf to point to the correct datadir (/data2)

---

<div class="post-metadata">

### Author: ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)
#### Post date: [April 20, 2022, 5:17pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/5 "2022-04-20T17:17:07Z")

</div>

Okay my.cnf contains include \*.cnf & !includedir  
/etc/my.cnf.d… basically it’s Piped into my.cnf.d. For sure you know that , you are an expert 😊.  
So removing var/lib/mysql … I think I have done that.

---

<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: [April 20, 2022, 5:19pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/6 "2022-04-20T17:19:26Z")

</div>

Ok. Then go through every config file and look for ‘datadir’ parameter and fix it.

---

<div class="post-metadata">

### Author: ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)
#### Post date: [April 20, 2022, 5:52pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/7 "2022-04-20T17:52:46Z")

</div>

I have checked every config file in that my.cnf.d directory everything I repeat all the datadir pointed to /data2 .

Datadir=/data2

---

<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: [April 20, 2022, 5:55pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/8 "2022-04-20T17:55:53Z")

</div>

And then when you start MariaDB, what do the logs say?

---

<div class="post-metadata">

### Author: ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)
#### Post date: [April 20, 2022, 8:06pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/9 "2022-04-20T20:06:40Z")

</div>

Error logs says failed to open log( file /logs/ mariadb -bin.000337’ error 14 ) nothing major .  
Can I move bar/lib/mysql to my datadir and give Mysql permission ?

---

<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: [April 20, 2022, 8:14pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/10 "2022-04-20T20:14:57Z")

</div>

After you started MariaDB, did you verify that nothing was create inside /var/lib/mysql? If stuff was created, then you’re still missing a config parameter somewhere that’s telling mariadb to keep using that directory. If nothing was created, and /var/lib/mysql is still empty, then you’re good. Just keep using /data2 as you are. You should also make sure that /logs/ exists and that this path for binary logs is also correct in your my.cnf

---

<div class="post-metadata">

### Author: ![Dba1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dba1/32/24223_2.png) [@Dba1](https://forums.percona.com/u/Dba1)
#### Post date: [April 22, 2022, 4:56pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/11 "2022-04-22T16:56:23Z")

</div>

Thanks a lot Mathew I haven’t been able to come back all these while . Var/lib/mysql consists of just perfomace\_schema, mysql, ibdata1 and yariyari…that’s all .still there is no config file elsewhere again. Even if I moved car/lib/mysql into my existing /data2. Problem still persists. In this situation what do you think 🤔

---

<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: [April 23, 2022, 3:20pm UTC](https://forums.percona.com/t/mysql-install-db-issues/15313/12 "2022-04-23T15:20:41Z")

</div>

If you completely erased var/lib/mysql, then started mysql, and now there is data in that directory, then that means your config is still messed up somewhere.
