I have an online sql database which is used by a PHP web-script.
I'm working with someone who is managing a local database on their computer.
I need a way to replace the content of my online sql database with the updated version from the computer, preferably using Windows Command Line. How can I do this?
You could use the mysql utilities to do this. mysqldump will create a backup of the updated database and then you can feed that into your online database using the mysql utility.
C:>mysqldump -uUSER -pPASSWORD DATABASE > database.sql
C:>mysql -hHOST -pPORT -uUSER -pPASSWORD DATABASE < database.sql
Related
so I'm not a server expert. Managed to migrate a server using Plesk's migration tool. All Plesk managed DBs were moved. But discovered that all DBs and users managed through MySQL were not migrated. Can anyone tell me a solution to this?
This is an expected behavior - Plesk Migration Tool will migrate only objects it knows about. Since you have some databases and users which are managed through MySQL directly, Plesk does not know anything about it, so they will not be transferred.
You should transfer such databases and users manually with mysqldump.
To create a backup of database with mysqldump you can use the following command:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin DATABASE_NAME > FILE_NAME.sql
To restore such database run:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin DATABASE_NAME < FILE_NAME.sql
Also you will need the mysql database which contains grant information. I do not recommend you to blindly transfer it and just re-create users.
Keep in mind that if MySQL version on target server is higher than on source you will need to run mysql_upgrade script to make changes in schema.
Alternatively you can export/import databases through phpMyAdmin which is shipped with Plesk and can be found at Plesk > Tools & Settings > Database Servers.
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
I want to copy all the tables, fields, and data from my local server mysql to my hosting sites mysql. Is there a way to copy all the data? (It's only 26kb, very small)
In phpMyAdmin, just export a dump (using the export) tab and re-import it on the other server using the sql tab.
Make sure you compare the results, I have had phpMyAdmin screw up the import more than once.
If you have shell access to both servers, a combination of
mysqldump -u username -p databasename > dump.sql
and a
mysql -u username -p databasename < dump.sql
on the target server is the much more fast and reliable alternative in my experience.
Have a look at
Copying MySQL Databases to Another Machine
Copy MySQL database from one server to another remote server
Please follow the following steps:
Create the target database using MySQLAdmin or your preferred method. In this example, db2 is the target database, where the source database db1 will be copied.
Execute the following statement on a command line:
mysqldump -h [server] -u [user] -p[password] db1 | mysql -h [server]
-u [user] -p[password] db2
Note: There is NO space between -p and [password]
I copied this from Copy/duplicate database without using mysqldump.
It works fine. Please ensure that you are not inside mysql while running this command.
If you have the same version of mysql on both systems (or versions with compatible db file sytsem), you may just copy the data files directly. Usually files are kept in /var/lib/mysql/ on unix systems.
I want to keep backup of my database and import it into different System? and how to make .dmp
or store file in MySql?
You can dump a database with the mysqldump command-line utility ; using a command like this :
mysqldump --user=USERNAME --password=PASSWORD --host=ORIGIN_HOST DATABASE_NAME > backup.sql
Then, as the backup is just a bunch of SQL instruction, importing it to another database is as easy as using the mysql command-line utility :
mysql --user=USERNAME --password=PASSWORD --host=DESTINATION_HOST NEW_DATABASE_NAME < backup.sql
And, as a couple of references to the relevant manual pages :
4.5.4. mysqldump — A Database Backup Program
4.5.1. mysql — The MySQL Command-Line Tool
and Chapter 6. Backup and Recovery
Read the manual. If there's something there that you're not sure about, ask a more specific question.
we've been making changes in the MySQL database, adding tables, columns and so forth and I have a development/staging site and production. All are MySQL, staging and production hosted remote.
How do I export the table structure and bring it into the production environment?
I have been using phpMyAdmin to administer it to date.
On local dev system:
$ mysqldump -u username -p databasename > export.sql
On remote system:
$ mysql -u username -p databasename
mysql> source pathto/export.sql
Check out mysqldump, a command line tool that comes with MySQL, here:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
Using it, you can take a snapshot of both the structure and the data of your database and import it elsewhere.