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.
Related
I used to rely on XAMPP in my Kubuntu 18.04 which located in /opt/lampp. I uninstalled the XAMPP and had a whole folder backup in this directory before that, and eager to install all the LAMP stack individually, which i installed apache2, mysql-server, and phpmyadmin after that.
The thing is, i want to import my databases from my backed up XAMPP folder located in /opt/lampp/var/mysql which consist of all my databases with tables in .frm and .ibd format, which is obviously exist, to my current installed mysql package database location in /var/lib/mysql.
After i moved those databases, i opened phpmyadmin to make sure the dbs imported correctly, but i only saw the database without the table inside the database. How come? What needs to be done to restore the tables inside?
You can't just copy database files from the datadir (/var/lib/mysql in your case). A proper MySQL/MariaDB backup is to generate .sql files which you can then import independently. It's not possible to selectively restore certain databases, due to the way certain files are managed (such as ibdata1 and perhaps others such as logfiles).
What I would try, and may or may not work, is this (the usual disclaimers about backups apply, I'm not responsible if your system becomes inoperative or catches fire, etc):
Make a back up of your existing databases (to SQL, I use the mysqldump command-line utility that ships with MySQL/MariaDB).
Stop the MySQL daemon and make sure it isn't running.
Temporarily move your current datadir out of the way (perhaps with a command like mv /var/lib/mysql /var/lib/mysql-current).
Copy your complete backup, the entire MySQL datadir (from XAMPP's old /opt/lampp/var/mysql), to /var/lib/mysql.
Start the MySQL daemon.
Connect and export any data you wish to save to SQL files.
Stop the daemon.
Move the current /var/lib/mysql out of the way (or if you're brave, delete it entirely).
Restore your original files from /var/lib/mysql-current to the original location in /varlib/mysql
Start the daemon again
Import the SQL files you've generated from step 6.
That's it — you should now be all set with your original data in your new database.
I am using digitalocean VPS. Accidentally I changed all files' ownership to www-data on my server. How can I get my mysql database copy from this server?
No backups? MySQL files should be in /var/lib/mysql or /var/db/mysql... look around, you may be able to change the ownership of those files and get mysql to start again, dump the db and start anew on another machine.
I created a new vps with digitalocean and installed mysql.
Then copied file permissions and owners from new vps to old vps.
Mysql worked again on old machine!
I would like to know How to restore MYSQL database after installing a different version of Wampserver. The explanation is as below:
I deleted the wampserver folder accidentally and I lost my MYSQL database. However, I have succeeded to restore the data folder that contains the database and I have installed another version of Wampserver (Actually, the old version of MYSQL that I was using was 5.5.8 , and the MYSQL version that I am using right now is 5.6.17) and I have tried to restore the database by copying its folder and putting it and the old ibdata1 file under the data folder of the new installation. But, unfortenately, that doesn't work.
So, my questions are:
Is it possible to restore MYSQL database after installing a different version of Wampserver (with a different version of MYSQL)?
If yes, how can I do that? What would be the solution?
In the past when this has happened to me, the only option that worked was to reinstall an older version of WAMP (i.e. MySQL) to match what my databases were created in originally.
If you install the same WAMP again, copying the folder should work now.
If you can gain access to your databases at this point, then you can do a proper backup of them using phpmyadmin or mysqldump etc.
After you get a proper backup, remove the older WAMP version and install the latest version again. Now you have to restore the databases using the backup files in order to put them into the newer MySQL version.
If you backed up your database you can restore it using your backup file. If you are using a graphical interface for mysql like PHPMyAdmin there is a import button you can use to import your .sql, .csv, .zip, or what ever extension you used to backup your database.
I installed Yosemite
Renamed MAMP to MAMP_old
Did a clean install of MAMP
Copied the db folder from old into the the new one
Now none of my databases appear in PHPMyAdmin
Inside the db/mysql folder I see the folder for my old databases, but there are no sql files. For example a Wordpress folder contains .frm files and db.opt files.
I tried doing this (using the link below), but I don't seem to have a mysql folder usr/local/
/usr/local/mysql/bin/mysqldump -u root -p[pass] [db] > [filename].sql
Can't access MySQL databases after upgrade to Mountain Lion (using MAMP)
What should I do to restore my old databases? I have very limited knowledge in this area.
Many thanks
I ran into this problem with upgrading to MAMP PRO 5 from 4. The following article proved invaluable:
https://appsolute.zendesk.com/hc/en-us/articles/215198946-I-upgraded-to-MAMP-PRO-5-and-I-am-missing-databases-
To quote:
Your old MySQL 5.6 data is in
/Library/application support/appsolute/MAMP PRO/db/mysql56_2018_xxxx
To be on the safe side, first make backups of your host data, and your
entire /Library/application support/appsolute/MAMP PRO/db/
To verify this is your old data, look inside of this mysql56_2018_xxx
folder, you should see subdirectories of all of your old databases in
this folder.
If you see missing databases in MAMP PRO 5, you can "reupgrade" your
old data by doing the following.
Quit MAMP PRO
Rename your mysql57 folder to mysql57_back
Make a copy of your mysql56_2018_xxxx folder, name it mysql57.
Start MAMP PRO, start your servers
Run Tools > Upgrade MySQL DB
Notes:
Instructions available online for MAMP (not MAMP PRO) may be misleading.
The above refers not to the /Library inside the package contents of the MAMP PRO app, but /Library from the root of your drive.
In my case the complete original databases were in the folder simply named mysql56. There were additional incomplete date-stamped folders suggestive of failures during the original DB update process.
Here is a link to an article which I think can help anyone in a similar situation:
How to Upgrade MAMP
So the basic idea is that you will need to copy your db files from the old MAMP folder to the new MAMP folder.
Another technique you could use would be do a mysqldump before upgrading, then import that dump file into the new version of MAMP.
I was working with XAMPP 1.8.3-3 on OS X Mavericks. After upgrading to Yosemite Mysql server stopped working. And an upgrade to XAMPP 1.8.3-5 fixed the problem and mysql server starts working.
Now the entire database list is showing on phpmyadmin, but no access to the tables. Its showing “#1146 - Table ‘DB_NAME.TABLE_NAME’ doesn’t exist”.
Unfortunately I don't have any DB backup!
I have the entire XAMPP folder backup. So how I can able to retrieve the mysql tables?
just type /Applications/XAMPP/xamppfiles/bin/mysql.server start
in terminal then start xampp
you can restore if you have all the mysql folders from XAMPP folder. (check /XAMPP/xamppfiles/var/mysql in backup)
if you have var/mysql folder, open and look for database names you had earlier.
there is a separate folder for each database you had earlier. open the folder and it will contain lots of files with table names.
if your old table engine is InnoDB you will see 2 files. with .frm and .ibd extensions.
or if you had MyISM it will contain three file per table which has .frm, .MYD and .MYI extensions.
after you verify you have all the required files in backup, you can start restoring them.
stop mysql
copy required database folder completely and paste it to currently installed folder. (/Applications/XAMPP/xamppfiles/var/mysql/)
start mysql
to restore web files, open htdocs folder in backup and copy required site folder to currentely xampp installed htdocs folder.
This solution worked for me. Good Luck !
Do a clean install. See my answer for my own question. xampp mysql server not starting. The bad part is that I'm not sure if it will save your database the way I explained. What you might try is going to xampp > xamppfiles > var > mysql > 'your database name' and making a copy of the database folder on your desktop and moving it back once you reinstall it. I tried and I think it might have worked had I changed the file permissions. You can also try experimenting to see if it preserves the database if you do this. I would do some serious testing if you really want to save your database before doing this.