Restore MySQL datatabases from the /var/lib/mysql backup - mysql

my database server crashed on ubuntu 20.04, but unfortunately my database folders were containing only the .ibd files. the /var/lib/mysql folder was copied, then mysql was re-installed. I have followed so many answers on how to restore the databases here but nothing seems to work

Related

How can I reinstall mysql while restoring DBs without mysqldump?

I'm running MySQL v5.7.25 on Ubuntu 16.04.5. Recently I noticed MySQL was not responding to any connects or service restart. I want to just purge the server and reinstall it but I have databases I want to retain and I can't use mysqldump to save them as sql files because I can't connect to mysql.
Is ther a way to do this, restore the files in /var/lib/mysql after a purge / reinstall. I've all ready archived the contents of /var/lib/msysql in a tarball, I just want to know if it's just a simple matter of copying the backedup files into the /var/lib/mysql directory before I pull the trigger.
don't use purge it removes everything. instead use remove
/var/lib/mysql folder stays untouched when you remove by using apt-get remove. D

Recover databases from backed up ibdata + frm files on volume

I've got ~ 30 sites worth of databases data on a volume on my server in the following directory /mnt/volume0/var/lib/mysql
The directory contains a 6.2G ibdata1 file and directories containing .frm files for each of the websites.
I'm trying to get dumps of the databases so I can move them to another server, however accessing mysql only shows the default databases (as datadir in /etc/mysql/mysql.conf.d/mysqld.cnf is set to /var/lib/mysql)
I've tried changing the datadir in /etc/mysql/mysql.conf.d/mysqld.cnf to /mnt/volume0/var/lib/mysql but mysql fails to start.
It was complaining about "failed to set datadir" which I fixed by running chown mysql:mysql mysql/ -R on /mnt/volume0/var/lib/mysql but now it's complaining about Failed password for root from xxx.xx.xxx.xx port 19192 ssh2
Any help is greatly appriciated!
Thanks
You can try to reset your password
mysqld_safe --skip-grant-tables
if you have here an error, then you have a bigger problem
mysql --user=root mysql
update user set Password=PASSWORD('your new password') where user='root';
flush privileges;
exit;
I ended up solving this issue by replacing the contents of /var/lib/mysql/ on my local machine with the contents of /mnt/volume0/var/lib/mysql/ (from the server).
I then encountered an error whilst trying to start MySQL Table 'performance_schema.session_variables' doesn't exist which I solved by upgrading MySQL on my local machine and restarting: https://stackoverflow.com/a/20262826/8231049
Now I'm able to dump the databases from my local machine :)
Edit: Can't accept my answer before waiting 2 days. Will do then.

Copy of innodb /data dir not working

I successfully installed fresh 5.6.27 mysql through homebrew.
Now I want to restore innodb databases from previous mysql install. I copied data/ dir from the old one to a new one. It contains ibdata1, ib_logfile1, ib_logfile0 and all databases as directories with the tables .frm as well as .ibd files.
my.cnf are same in both installs.
However the new 5.6.27 is not loading databases after the restart.
Any tips?
Ok, I found that this brew install did set up data dir at /usr/local/var/mysql.
ps auxww|grep [m]ysqld helped to reveal that.
So I just copied there, restarted and voila, dbs are there.

How to restore full mysql (dir)

My problem is: I'm saved the /var/www/virtual and the /var/lib/mysql directories. And after reinstall OS I set up the MySQL and when restored these two directories i'm got error in mysql server. So MySQL server don't want to start up.
So what way can i restore the mysql database directory?
The MySQL server don't start after I copy the ibdata1 file.

How do I restore MySQL DB from backup

My server recently crashed and I have backed the Mysql files using raid.
BACKED UP DIRECTORY
/backup/var/lib/mysql
I installed new OS(RHEL5.3) to my server and I want to restore my DB to MySQL
How do I do this?
I know you can ssh mysql > the dump files
but, these backed up files are not in DUMP.
They are separated as .MYD .MYI .frm etc..
I guess your backup file is not in the same server as your database.
Try:
scp -r /backup/var/lib/mysql/* DB_SERVER:YOUR_NEW_DATABASE_DIRECTORY
Then
ssh DB_SERVER
.. restart your mysql daemon (easier)
.. or flush privileges, flush tables ...
Copy these files directly to your mysql data directory, and you will be able to access them in MySQL. That should help you!