Restore the mySQL database from files - Windows server - mysql

I have tried everything I can find now for over 3 days straight to recover a mySQL database on Windows.
What happened?
I have a Windows Server 2012 that crashed which had WordPress on it and the MySQL 5.1 database for WordPress with no backups. Is there no way to recover from this with a database backup even if you have all the files?
What I have tried!
Attempt 1 recovery (try to add the database from the crashed server to the current mySQL instance):
I reinstalled a new MySQL 5.1 on to the new Windows Server 2012
system and I moved just the /data/wordpress953 folder over
“completely” from the crashed system (which was working fine) into
the /data folder of the new MySQL install.
I start up MySQL and login just fine. I see my database. I see all the tables. However, if I go to a table to view it and I get the following error.
1146 = Table ‘Wordpress953.wp_commentmeta’ doesn’t exist
Attempt 2 recovery (try to completely replace the current mySQL instance files from the crashed server on top and overwrite the new instance):
I completely move over the /data folder from the old server replacing it on the new server
I completely move over the /program files/mysql folder over from the old server onto the new server
I completely move over the /program files (x86)/mysql folder over from the old server
I startup mysql and go to phpmyadmin and get the following error when I try and login:
1045 Cannot log in to the MySQL server
I figure I just need to fix the root password so I attempt to change the root password using this process https://www.youtube.com/watch?v=dyc5b3yT2tI but it fails to even start mySQL to change the password.
Please help with an answer of something I haven't tried....

Ok, I got it!!
The procedure is.
Install vanilla mySQL on new server (I had already done that)
Stop mySQL service
Move ONLY the C:\Program Data\data\wordpress953 (the innodb database you want to restore) folder over “intact” “as is”.
And, move ONLY the ibdata1 file and ib_logfiles off of the original C:\Program Data\data\ root to the new mySQL server. Leave the C:\Program Data\data\mysql folder “as is” from the vanilla install
Re-Start mySQL service
It was a bit of a puzzle because it was basically an “incarnation” of what I was doing but you have to only change/do certain things. The C:\Program Data\data\ibdata1 file down one level in the root went with the C:\Program Data\wordpress953 folder but apparently not with \mysql.

Related

Cannot find mysql bin file in macos

I am having a lot of problems with mysql on macos 10.14. It started with trying to reset my password. Back when I collaborated with someone in 2018 my collaborator used mysql but I did not know how to work it. I have a feeling that the password I used for mysql is not the typical password I used because my attempts to log in failed. watching this video I was told at 9:12 that the password would be set on installation but that turned out to be false. I was never asked for a password upon downloading but perhaps that is because I had part of mysql already downloaded on my computer but I did not have the workbench installed. All of my attempts to reset the password failed. So I then tried deleting mysql and redownloading. Now I am not able not to start the mysql server from mac's system preferences. But that's not my largest problem. I still cannot reset the password and hence even use the app. Following official mysql instructions I cannot reset the password because it requires the location of a pid file. It says
Stop the MySQL server if it is running. Locate the .pid file that contains the server's process ID. The exact location and name of this file depend on your distribution, host name, and configuration. Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/.
In the folder for mysql located in /usr/local/var/mysql there is no pid file. A lot of the tutorials I've seen recommend using terminal but I cannot use terminal for mysql because I get the mysql command not found error. Ok, so to fix that problem trying this tutorial here it says:
If you’re installing MySQL using the official installer, then your MySQL bin/ folder should be located on /usr/local/bin/mysql
So now I need to find the mysql bin file but when I write ls in the /usr/local/bin folder, mysql does not come up. All of the file beginning near 'my' are
multinit
murge
nasm
So I'm stuck. I find it simply incredible that such a simple thing as resetting a password is so difficult.
Let’s say we installed MySQL version is 8.0 on our Windows OS. The bin directory is present at the following location −
C:\Program Files\MySQL\MySQL Server 8.0\bin

MySQL Workbench Unable to Retrieve Disk Space in Data Dir, Server Stopped

I had mySQL workbench working fine a few weeks ago. Now, any time I log in, I get no connection. Upon inspecting Sever Status, it is showing Stopped. Also, under the Server Directories, it says Unable to Retrieve next to Disk Space in Data Dir.
I also noticed that the configuration file was wrong, or outdated? The Configuration File originally read:
C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
But I looked and there was no MySQL Server 5.5 file in my directory. I do have a MySQL Server 8.0 folder, so I changed the Configuration File to:
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
However, this fails to solve the problem. I've also attempted to run Services from the Start Menu, right click on MYSQL80, and choose start - and it says the service has Started then stopped.
I'm not even sure this missing or mis-directed file is the issue, or whether it's the Unable to Retrieve Disk error (or both are causing the server to fail). I recently changed my login password for my computer - but I doubt that is related to the login credentials for MySQL, right? (I see MYSQL80 properties has password for 'log on' option, but I have no idea what this password even is, or how to change it).
I've also read about this problem online and cannot seem to find an answer that solves the issue. I've tried running MySQL Workbench as an admin too, and that doesn't work either.
Can anyone point me in the right direction? Is there a way to get the server up and running again without a bunch of complicated command line? I appear to have mysqld.exe in the bin file in MySQL 8.0
Thanks all in advance!
In MySql Workbench Server -> Startup/ShutDown -> Start Server.
This Worked for me.
When the my.ini file is messed up I think the best solution is a total uninstall/delete and manual install. Before you do any of the following make sure you go to your current data dir and save your database folders. Then dlete all of your current MySQL related directories and uninstall MySQL and MySQL workbench.
I had this problem when I installed MySQL 8.0.15 with the community installer. The my.ini file that came with the installer did not work correctly after it had been edited. I did a full manual install by downloading that zip folder. I was able to create my own my.ini file containing only the parameters that I was concerned about and it worked.
download zip file from MySQL website
unpack the folder into C:\program files\MySQL\MySQL8.0
within the MySQL8.0 folder that you unpacked the zip folder into, create a text file and save it as my.ini
include the parameters in that my.ini file that you are concerned about. so something like this(just ensure that there is already a folder created for the datadir or else initialization won't work):
[mysqld]
basedire=C:\program files\MySQL\MySQL8.0
datadir=D:\MySQL\Data
....continue with whatever parameters you want to include
initialize the data directory by running these two commands in the command prompt:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --default-file=C:\program files\MySQL\MySQL8.0\my.ini --initialize
install the MySQL server as a service by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --install --default-file=C:\program files\MySQL\MySQL8.0\my.ini
finally, start the server for the first time by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --console

How to restore mysql database in XAMPP

I have been using XAMPP on Ubuntu for a while and I had created a DB via phpMyAdmin with a single DB and multiple rows.
After having to restart my PC, I could not restart XAMPP, so I did install it again (ran the installed.sh without installing first)
Installation was successful and web server is working fine with old files retained.
But, I find that I cannot access the table any more, even though I see it listed via phpMyAdmin and gives an error "Table does not exists in the engine".
However, I can see the table.ipd, table.frm and db.opt inside /opt/lampp/var/mysql/
Is there a way to restore the table from the XAMPP stack?

MySQL corrupts after every server restart

I Have a bit of an odd problem. I am running MySQL and Drupal site from a windows environment (not by choice but it is just how things have worked out) and most of the time the site is fine however every time the server is restarted (from updates or for maintenance) The MySQL Database will corrupt.
When I log in to MySQL Work bench I notice that the server status is stopped and when I try to start it I get the error:
ERROR Fatal error: Can't open and lock privilege tables: Can't find file: 'user' (errno: 2 - No such file or directory)
and then MySQL Server fails to restart.
The only way around this problem is to delete data folder in the ProgramData/MySQL and then replace it with a backup from a fresh install of MySQL then import a backup of my tables and recreate my users.
My Question is what is causing MySQL to corrupt at every sever restart and what can I do to prevent this happening moving forward?
This occurs when mysql can not find or do not have permissions to user.MYD or user.MYI or user.frm in the data directory. When you start mysql, make sure that these files exist in data directory. You can just copy those files when mysql does not start
This worked for me:
Stick with the 32 bit.
Uninstall and make sure you then DELETE the mysql-data folder and all its subfolders before installing, and prefer to use the 32 bit (sometimes 64 bit versions are the problem).
(Source)

Migrating MySQL databases from files only

On a fresh install of MySQL on Mavericks (via Homebrew if that matters) how can I take database files from a back up and migrate them to /usr/local/var/mysql in the new instance? I have a directory for each database and one huge ibdata1 file.
If I move them by a simple file transfer, start the new instance and log in, each database is there however no data is present when I check a table.
it should work if keeping or upgrading server version. Make sure ownership and permissions are correct. Then run mysql_upgrade which will adjust the files.