I have a hard disk that MySQL 5 has been installed on it (this hard disk belongs to another PC with Windows XP) and I've connected it to my PC. How can i copy its MySQL data to another MySQL 5 ??
thanks in advance.
you can try this.
Shut down both mysql server.
Locate the mysql data directory (e.g. /. If your database use myisam as engine you will find for any database a folder. In this folder are the files for each table, indexfiles and datafiles. Copy the folder to the data directory on your pc.
Start your mysql server.
PS: Check the version of both servers.
Or you can use mysqldump this is an command line utility for mysql. After export copy the export file to your server and use this command:
mysql -u<username> -p<password> < <exportfilename>
Kind Regards
Related
I have a dead hard drive. I've connected it with SATA to USB IDE and can recover files. Also the filesystems looks good. How Can I get a dump of database from that hard drive. The laptop I'm using also has mysql installed in it. I'm using xampp. I've tried the following command.
G:/xampp/mysql/bin/mysqldump -u root -p uma > D:/umaoldbackup.sql
This is not giving dump of a latest data. And I think it's giving dump from my local computer.
Please help.
Correct, mysqldump connects to the running MySQL Server process on your local computer, not the data on your sick hard drive.
MySQL client applications like mysqldump do not read the data files directly. They connect to a MySQL Server process and make requests for the data. Before you can access that data, you need to restore the data files to the data directory of an instance of MySQL Server.
Stop the MySQL service.
Copy data files to the data directory of your MySQL service. Move any existing data files to someplace else that is safe, if you want to bring back that data after exporting your umaoldbackup.
Start the MySQL service so it can read the files in that data directory.
You should probably get someone to do this for you if you don't know how to start and stop services on Windows.
Re your comment about where is the data directory...
I'm not a user of Windows or XAMPP.
It's probably actually C:\xampp\mysql\data according to What is the exact location of Mysql database tables in XAMPP folder?
But you can confirm that by connecting to your current MySQL service with a client and running the following query:
SELECT ##datadir;
I'm trying to restore MySQL database from a folder with frm, MYD, MYI files.
As my partner shown (remotely) that it works only copying the database folder into data folder under mysql installation path, for me it's C:\Program Files\MySQL\MySQL Server5.5\data.
I found some answers here saying the same way doing this. But it didn't work for me. Did I miss something?
I tried restart the MySQL service, still got no luck.
Any ideas? Thanks in advance.
This could be possible because of some permissions problem, do you have access to those folders in which mysql .frm, MYD, MYI files are located?
And also there is a better way to restore your database, this is more popular and preferred one.
mysqldump --single-transaction databasename > database.sql
You can also dump the database in a particular folder
mysqldump --single-transaction dumptest > ~/database.sql
If you are specific about copying folders, please follow the steps by Rolando on a windows machine, here
Suggestion:
if you have the apache installed, you could consult the database in php myadmin. It worked once for me. Then you can copy the files to a folder and import it to mysql workbench or whatever you use.
Give it a try if the database was originally in your computer.
Finally, I figured that I should use the same version of MySQL as my parter's.
I also encountered a problem is that the data folder is different after I installed the version 5.7.x, it's C:\ProgramData\MySQL\MySQL Server 5.7\Data for my environment, which is a hidden folder by default. It can be changed in my.ini with datadir as its key.
I was on windows and using XAMPP(installed somewhere else than C:/ )
Now i have moved on to LINUX and installed LAMPP.
So, i have this XAMPP folder from windows and i copied the project files from htdocs and now i need the database which i didn't exported while i was on windows.
I tried to copy the phpmyadmin folder from the old XAMPP folder but couldn't get it to work.
So how can i access the previous OS phpmyadmin to use my existing databases -
using linux (MINT - rosa-cinnamon)
Thanks in Advance !
If you want to move databases between hosts - especially when there are differences in the MySQL daemon version, operating systems (-versions) or storage schema - you should create a MySQL dump at host A and import it on host B: http://dev.mysql.com/doc/refman/5.7/en/mysqldump-sql-format.html
If this is no option for you anymore, you can try to move the old MySQL data directory (Configured in my.ini on windows, somewhere in the xampp directory) to the location where the new MySQL daemon stores its data files (Normally configured at /etc/mysql.my.cnf). A few more hints on this:
Ensure to modify the file permissions on the data files at the new location that the MySQL daemon can work with them.
On Windows, MySQL table names are case insensitive. On Linux they are case sensitive. Keep that in mind, if your application complains about missing tables.
And of course: Test this with backups only!
My PC crashed and I lost my WAMP files. Although I have a copy, I do not know how to retrieve the database. Can I copy the WAMP files to another system and then access phpMyAdmin or something? I think it's not possible.
Any other ways where I could do so? I have tried re-installing. But I have no idea how to retrieve them. All I have is just a copy of the WAMP server folder.
You can make dump for necessary databases
Open CMD and type
[Replace brackets and information inside with your parameters]
\wamp\bin\mysql\{mysql5.5.24}\bin\mysqldump.exe -u {root} -p{} {dbname} > \Users\{username}\Desktop\dump.sql
The opposite action its:
\wamp\bin\mysql\{mysql5.5.24}\bin\mysql.exe -u {root} -p{} {dbname} < \Users\{username}\Desktop\dump.sql
I have using VPS that had to be re-imaged. my DB was part of it and it was being backup up as the app wasn't in production yet. However, there is some data that I wish to recover on it. the VPS provider is giving me a backup of the image (Ubunto Linux) that has all the files.
Is there a way I can recover my data?
The mysql data files in Ubuntu are located at /var/lib/mysql
To restore your database you need:
1) create new database named as old one
2) stop mysql server
3) copy old database files from /var/lib/mysql/your_database_name/ to new system
4) start mysql server
Your database will be restored.