Mysql_install_db issues

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

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/

1 Like

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

1 Like

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

1 Like

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 :blush:.
So removing var/lib/mysql … I think I have done that.

1 Like

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

1 Like

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

Datadir=/data2

1 Like

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

1 Like

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 ?

1 Like

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

1 Like

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 :thinking:

1 Like

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.

1 Like