Import/Exporting databases from one machine to another - mysql

I have two PCs, one is Ubuntu 8.10 and the other Ubuntu 9.10. On the Ubuntu 8.10, i have a few databases in phpmyadmin which i would like to copy across to the Ubuntu 9.10 phpmyadmin(which has no databases).
I'm not sure if i'm on the right path but here's what i think i should do:
Export the databases onto Ubuntu 8.10. And copy those files(.sql) and paste them onto the Ubuntu 9.10 PC in a folder or something. Then import these .sql files into phpmyadmin on Ubuntu 9.10.
Is there a better way to do Copy the databases across?
Thanks.

From the main screen of phpMyAdmin (visible right after login) there are "Export" and "Import" links. Use these facilities to export your database (to a file on your computer) and then to import that file on the destination host.
Alternatively, if you have shell access to both machines, you could use the command mysqldump:
mysqldump --password=PASSWORD -u root DATABASE > INSERT_STATEMENTS
and then simply create all databases on the destination host with
mysql -u root --password=PASSWORD < INSERT_STATEMENTS

There's als MySQL Administrator that comes in the MySQL GUI Tools package. Since you've got access to both machines this is probably the easiest solution. Although I believe it just uses mysqldump, the GUI makes it a lot easier.

Related

How to import database without having .sql file?

I have removed Windows from my laptop and booted Ubuntu and want to import my databases from xampp. They are located on xampp folder but I don't have .sql files created for every table.
You still need to export your databases to sql files from windows which you can then import into Ubuntu. The structure and information schemas of those database files inside Data directory are stored in internal database and so copying and pasting the data folder might corrupt them and render them unusable. In windows you can use command line to dump the databases mysqldump -u username -p database > database.sql then import the database in Ubuntu.
The easiest way is to install xampp on your ubuntu (read this:
Install xampp on ubuntu 16.04
)
after that, move data folder from old xampp/mysql to new path.
now, you can use your xampp on ubuntu, or export and import your db by command line (How to Back Up MySQL Databases From The Command Line) or phpmyadmin to your mysql server

Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql

Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql, but it is creating only empty database in phpmyadmin of linux.
Please some one help me to solve this issue, i have only these files backup with me
The best way is-
Step1: Take backup from windows by mysqldump-
mysqldump -uroot -proot123 -A > backup.sql
Step2: Move this backup to linux, you can use winscp tool for it.
Step3: Now restore this backup to linux machine.
mysql -uroot -proot123 < backup.sql
Modification:
It seems your db engine is myisam and you just coppied file/folder from window to linux, so give permissions as per below-
chown -R mysql.mysql /var/lib/mysql
First create a .my.cnf file containing the mysql root password in your users home folder, on linux.
On windows, there exists a .my.ini or something which serves the same purpose. That way you will not have to reenter your passwords a lot during the next steps, which you are very likely to repeat several times until you get them right, I fear. :)
Since unix/linux and windows have different ways to save files, you might very likely run into errors during a simple copy-restore process, depending on how you copy files.
Your best bet is likely copying the original mysql folders to another windows machine and save them accordingly, such that mysql can find them. (With an installed mysql instance, of course.) I don't know what else you might need, if the databases are not found instantly, since I never had to do this prior and have no test setup here to check this case out.
When the databases are found through the mysql on the WINDOWS server, from the mysql cli prompt there look up which encoding etc the db uses:
SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;
Then create a new database on the LINUX server with the same name and the same encoding's from MYSQL CLI:
create database <db-name> character set <charset> collate <collation>;
Then on the WINDOWS server in a CMD window, do a mysqldump which should look familiar on windows like on linux:
mysqldump <db-name> > <db-name>.sql
Then copy the dump over to the LINUX server and replay it:
mysql <db-name> < <db-name>.sql
Afterwards you will have to recreate a user (if you know which user and password your web app used to access the database, create a new user with these credentials and grant him full access on your database.
If you do not happen to know the credentials anymore, create an arbitrary user and then change the database credentials in the configfile of your web application.
In case you have problems, check the unix file permissions of the files you copied, such that mysql can access them.
Good luck, mate.

Mysql56 for Windows does not recognize any new database

As the title says, i have a fresh install of mysql56 server for Windows(currently installed on windows 8.1) and the server does not recognize any of my new databases. I've copied a pack of databases from a old hosting and just put them in the "data" directory of the server.
I've tried to restart mysql(process & service) but nothing changed.
Edit: I've created a new database with a new table but the server does not store the new database in the "data" folder. If the data is not stored in the Mysql/Data directory then where?
There are several ways to go. But (like for virtually all databases), you must do some kind of explicit "export/import", or "migration". You cannot simply copy the raw database files into a directory.
My preference is to use good old "mysqldump":
For example:
mysqldump -u username -ppassword –all-databases > dump.sql
You'd then restore on your new Windows install with a command like this:
mysql -u username -ppassword database_name < dump.sql
Here are more details:
http://dev.mysql.com/doc/refman/5.0/en/copying-databases.html
PS:
This tutorial shows you how to export/import with phpMyAdmin (even easier!):
http://www.techrepublic.com/blog/smb-technologist/import-and-export-databases-using-phpmyadmin/

get the copy of database from mysql

Let's say I remote from my workbrench to the database which is on server now for some reason I need to have copy of the database on my another computer as a local database. How can I do that?
Export it to a single file (whatever.sql), then import it by running the script on your local computer.
There's a "Data Export" link on the left side if you connect to the remote server using MySQL Workbench. Click on that and go through the export process. Then connect to your local server, click on "Data Import/Restore", and choose the file you just saved.
First export data from database, then import database or specific table import in local server.
$ mysqldump -u [uname] -p[pass] [dbname] > [backupfile.sql]
To dump all MySQL databases on the system, use the --all-databases shortcut:
$ mysqldump -u root -p --all-databases > [backupfile.sql]
Source :How to Copy (Backup) a MySQL Database
In addition to a dump and restore you can try the MySQL Workbench migration module which allows to migrate from MySQL to MySQL (useful for instance to upgrade from a previous version or to copy a schema, as in your case).
MySQL Workbench migration (general description, video tutorial, white paper): http://www.mysql.com/products/workbench/migrate/
The MySQL Workbench migration wizard: http://dev.mysql.com/doc/workbench/en/wb-migration-wizard.html

Combining two installs of mysql

Noobish questions
The StartupParameters.plist points to MySQL 5.5.27-community. When I run Querious, a database management application, and create a db, it adds the db to an older version - MySQL 5.5.18 (specifically to usr/local/mysql-5.5.18-osx10.5-x86_64/data).
Questions: how do I move the dbs in the older version of MySQL to the current one? If I do, and then delete the old MySQL directory, will I be ok or are there other changes which need to be made?
Thanks,
Cole
You should simply dump the old databases using mysqldump or similar. Then import those dumps into the new server. You should then be able to safely uninstall your old server and remove the directories.
This is a simple case of exporting the databases and then importing them to another. In your case, use mysqldump to export the database from the older server and use mysql import to import into the newer one.
It is okay to safely uninstall the older version once the database has been exported.
usr/local/mysql-5.5.18-osx10.5-x86_64/> mysqldump -u username -p database > exported.sql
(location of the newer db)>mysql -u username -p -h localhost database < exported.sql