I crashed my first Ubuntu installation by changing some distribution stuff (now stuck in login loop, even in shell).
So I installed Ubuntu again on my second hard drive from which I can access the crashed Ubuntu setup.
And since I can't start Apache2 or reach the MySQL server there anymore, I'm wondering if there is a possibility to duplicate the MySQL data just by copying files from one hard drive to another.
Or maybe someone has an alternative idea to restore the MySQL data?
You can create a database of the same name on the other computer and then transfer the content of /var/lib/mysql/_dbname_/. Stop before the copying and start after it.
Related
I have an error with Xampp where it will not connect to my database. I have had this error several times in the past and no solutions have helped. I find that uninstalling and reinstalling ends up being the fastest method, however, by doing so I lose my database tables. As I have no access to the default export and import functions, I was wondering how I transfer the tables across.
Last time, I copied and pasted these files into the same directory when I reinstalled Xampp and the tables transferred but the data within did not. The tables had also lost some functionality as well.
If anyone has any methods to do this I will greatly appreciate it.
The best way to backup and restore your data is to dump the database to an SQL file. You can use the provided mysqldump tool for that, which is the best tool for the job.
Copying the entire MySQL "datadir" (which is probably one level up from the screenshot you've posted) and completely replacing one of your new stopped MySQL instance will probably work, but is not reliable and is not supported. Since there are other files (such as ibdata1) that handle the overall health and functioning of the entire MySQL instance, you can't only copy over individual database directories. Furthermore, you should only do this when the original and replacement MySQL servers/daemons/services are completely stopped because otherwise there are file corruption or concurrency issues.
Since you're running the server on your own computer, you should grant yourself sufficient access to be able to use mysqldump and use that regularly as a backup, since file-level backups of the data directory are not reliable.
I recently had one of my VM's go down (MS Server 2016) and the only version I am able to get up and running is two weeks old. However, I do have a backup of my C:/ drive from last night that has my C:/ProgramData/MySQL and C:/Program Files/MySQL in order to restore my databases can I simply shut down MySQL service, copy/replace the folders in my VM, and start MySQL again?
[SOLVED] As stated in the comment below:
Copying the entire C:/ProgramData/MySQL folder did not work for me, the MySQL service would not start. Instead, copying just the contents of C:/ProgramData/MySQL/MySQL Server 8.0/Data solved the problem. The service started with no errors and all my data was recovered.
I have been running MySQL 5.X for several years. Just come to a new server and downloaded V8.0.11.0. I installed it and it asked me no questions about where to keep the data, it has put it all on the C: drive. I want to keep it separate to make backup easier. How do I make the data location move to another disk?
What I have tried:
The old 5.7 method of stopping the server, moving the files, updating
my.ini and restarting. You can't move the files (Access denied) and
the server doesn't start if you change the my.ini file.
mysqld --initialise --datadir="F:\MySQL\Data" (tried forward slashes and double slashes as well)
I can't find any documentation! It's a pretty basic requirement so I'm guessing it must be documented!
OK, I uninstalled MySQL and then ran the installer again. The first question is where do you want to put things! I take it all back, apologies for missing it!
I've been using XAMPP for several local projects.
A few days ago I installed Desktop Server for Wordpress local development.
Little did I realize, I wouldn't be able to open the regular xampp back up...
Now I need to export the databases I've created on xampp without being able to access the old phpmyadmin.
How can I do that?
Thanks!
It sounds like you have two MySQL instances on your machine. If one is using the MySQL networking port (3306), the other won't be able to start, which is consistent with what you're describing.
If you stop the one (from Desktop Server) then manually start the other one (in XAMPP, which you should be able to do from the XAMPP control panel), you can then connect to it and export your database.
You can't safely merge the two database data directories, but in theory if you completely stop both MySQL instances — and back everything up — you should be able to completely replace one datadir with the other. I don't generally advise this, because the possibility also exists to lose your data.
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)