How can i transfer a database in SQLyog? - mysql

I use SQLyog Ultimate ver11.11 on windows8.1. I need to transfer a database from another machine (which it uses SQLyog Ultimate ver11.11 too). What is easiest way for do it?(I mean how can i detach an already existing database in another machine and then attach it to mine?!)
Thanks in advance.

Follow below steps :
1) Export database from old system SQLyog. (You can find export option on right click of database)
2) Create database in second system with same name.
3) Import database to second system SQLyog.
Note : I would recomment to use mysql command line.
Just for your information.
For export : mysqldump databaseName > databaseName.sql
For import : mysql databaseName < databaseName.sql
Note : Make sure, you have created your database before importing, otherwise it will give you error with message database not found.

If you can connect to both databases then you can use SQL-Yogs copy database command, just right-click on the database to copy in the database list.

Related

How to copy table from a database on SERVER 1 to another database on SERVER 2 using phpMyAdmin?

I have a database named db_x on server X (running WHM) and another database named db_y on server Y. I connected to server X via SSH made some changes to the phpmyadmin configurations to allow it to connect to db_y via phpmyadmin on server X via cPanel. Now, I want to move all the tables of the db_x on server_X to another database(db_y) which is on different server(yy.yy.yy.yy) by using phpMyAdmin from server_X.
Is there any way to do so? Please help me.
Edit: The table is over 3 GB, so export/import won't work.
due to the size of your database you will not be able to succeed with phpmyadmin.
Try use the SSH.
Upload the database to the new server "old_database.sql".
Considering that the database already existis on the new server, use the command below:
# mysql new_database < old_database.sql
This command will import your sql file into the new database.
If you don't have the old_database.sql file, you can also obtain it with command in old server
# mysqldump mydatabase > old_database.sql
This command will generate an SQL file from your database.
Ther will be an option export in db_x export it and in db_y click import
and chose downloaded file wich was exported and click run.

MySQL Workbench - How to clone a database on the same server with different name?

I am using MYSQL Workbench and I want to clone a database on the same server with different name. It should duplicate the all the tables structure and data into the new database.
I know the usual way is probably using data export to generate a sql script of the database and then run the script on the new database but I encounter some issues with it.
Anyway, is there any better way or easier way to do so?
You can use migration wizard from MySQL Workbench. Just choose the same local connection in both source and target selection, then change schema name on manual editing step. If nothing appears on manual editing step click next and the source and targets will appear. Click slowly on the source database name and edit to the correct name. Go thorough to the end and voilĂ  - you have two identical databases with different names. Note you must have created the target database already and granted permissions to it for the MySQL Workbench user.
I tried to do it in MySQL Workbench 8.0. However I kept receiving an error regarding column-statics. The main idea is to use mysqldump.exe, located in the installation directory of MySQL Workbench, to export the data. So, supposing a Windows oriented platform:
Open Powershell, navigate to mysqldump.exe directory. In my case the command is:
cd C:\Program Files\MySQL\MySQL Workbench 8.0 CE
Export database by executing mysqldump providing the right arguments:
./mysqldump.exe --host=[hostServerIP] --protocol=tcp --user=[nameOfUser] --password=[yourPassword] --dump-date=FALSE --disable-keys=FALSE --port=[portOfMysqlServer] --default-character-set=utf8 --skip-triggers --column-statistics=0 "[databaseName]"
Without changing directory, import the exported file (.sql) by using the following command in Powershell:
Get-Content "[pathToExportedDataFile]" | ./mysql.exe --user=[nameOfUser] --password=[yourPassword] --port=[portOfMysqlServer] --host=[hostServerIP] --database=[nameOfNewDatabase] --binary-mode=1
You can check in the documentation here for more information regarding the mysqldump options.
Please note the following:
Do not forget to replace the values in [] with your own values and remove the []. Do not remove the quotes("") where the are present.
Do not switch Powershell for cmd or something like git-bash, since the above will not work.
As far as step 3 is concerned, I created the new database from MySQL Workbench and then ran the powershell command.
List item First, create a new database using CREATE DATABASE statement.
Second, export all the database objects and data of the database from which you want to copy using mysqldump tool.
Third, import the SQL dump file into the new database.

Importing Data and Schema to MySQL Workbench

I'm trying to learn SQL and I downloaded a database to practice. I downloaded two files of extension .sql, one is the schema and the other one the actual data. I've also installed MySQL Workbench. I've been googling and I've been trying things to solve this but I don't understand Workbench and I can't load the database.
Where do I import the schema and the data in order to try queries ?
Any help would be really appreciated.
This is simple in Workbench, and I'll use the freely available sakila database as an example. Feel free to apply this to your situation:
Download "sakila" from here: http://dev.mysql.com/doc/index-other.html
Extract it somewhere, in my case, onto the Desktop into a new sakila-db/ directory
Open Workbench
In the Schema Navigator, right-click an empty area and choose "Create Schema"
In the schema creation wizard, name it "sakila", keep the defaults, hit "Apply", finish wizard
Go to "File" -> "Run SQL Script..."
Choose "sakila-schema.sql", make sure "Default Schema Name" is blank or select "sakila", execute
Go to "File" -> "Run SQL Script..."
Choose "sakila-data.sql", execute
Click the "refresh" icon in the Workbench Schema Navigator (or restart Workbench)
Now, use the populated sakila database :)
Steps (4) and (5) are optional in this case (as executing sakila-schema.sql creates the schema), but the idea is worth mentioning.
Here's how it would look when loading th script into the SQL IDE:
The accepted answer is from 4 years ago, so I thought I'd give an update as in MySQL Workbench 6.3 the procedure is a bit different.
You have to select the menu item Server -> Data Import -> Import from Self-Contained File and select the SQL file containing the database you want to import.
In Default Target Schema, select the database you want to import the SQL dump to, or create a new empty database via New...
Then click on Start Import.
You could use mysql console from terminal. Login through the user id and pass. Then create a Database from the following command is the .sql file does not have one such command to create so.
Create database db-name
use db-name;
SOURCE xyz.sql;
Source command would load the the content from xyz.sql to your database created. This would be reflected later in workbench indeed.
Its very easy on Linux platform just follow below mentioned steps, After downloading zip file of sakila-db, extract it. Now you will have two files, one is sakila-schema.sql and other one is sakila-data.sql.
Open terminal
Enter command mysql -u root -p < sakila-schema.sql
Enter command mysql -u root -p < sakila-data.sql
Now enter command mysql -u root -p and enter your password, now you have entered into mysql system with default database.
To use sakila database, use this command use sakila;
To see tables in sakila-db, use show tables command
Please take care that extracted files are present in home directory else provide the absolute path of these files in all above commands.

How to copy a database using HeidiSQL?

I have a local installation of MariaDB on a Windows XP.
I created an empty database db_y which I wanted to populate with the tables of the database db_x which I exported as a dump-file from a MySQL-instance (with HeidiSQL). When I imported the dump-file db_x.sql into the the MariaDB instance:
c:\ > mysql -u root -h localhost -p db_y < "X:/archive/db_x.sql"
I got the following:
- MariaDB-inst
+db_x
+db_y
db_y remains empty and db_x from the dump-file was added (db_x is the database name of the original database I exported). What I have to do to get the desired database name? I thought I could change the database name in the db_x.sql file but I didn't want to open such a large file. Can I change the import command above in such a way that it change the database name?
I'm also interested in this kind of solution:
CREATE DATABASE y FROM DATABASE x
Is something like this possible?
In the net I find the solution RENAME DATABASE which was not recommended and ALTER DATABASE db_x UPGRADE DATA DIRECTORY NAME
but sincerely, I preferred to create a new database with the new name.
Thanks for any help.
Consider you have two databases: source_db and target_db. If you want to copy the database contents from source_db to target_db you should do as follow in HeidiSQL:
Right click on source_db then select: Export database as SQL.
Now change the value of Output and select Database.
A select box will appear, select target_db and that's all.
There is an easy way to transfer a database from one instance to another with HeidiSQL:
Create the database db_y in instance y
Click on dump icon (or right click). The instance y should be activated.
At "Output" option choose Database
At "Database" option choose db_y
Select on the left the instance x and database x
Export
Try MySQL Workbench. It's made by MySQL and I've found it excellent for backing up a database and restoring it under a different name.
http://dev.mysql.com/downloads/workbench/
HeidiSQL's export dialog recently got a new option called "Max INSERT size". This controls the number of rows in bulk/multiple INSERT commands.
Also, there is a documentation for this export dialog.

copy and create new mysql setup on server

Iam a newbie for DB. I have a running database on godaddy's mysql setup. Now i have a new server whose access is not with me. I have to make a file which can install and create new mysql on that server plus it can copy and store specific tables from my current server database too.
I have to give this file to the person who is having the access so that he can execute it and can have all the content. How can i make such a file?
You can use MySQL's mysqldump to take backup of your databases.
Alternatively, You can always backup your database using MySQL GUI tools like SQLyog.
I guess GoDaddy do not allows direct connection for mysqldump to work. In that case you can use SQLyog's HTTP tunneling capability.
Give the generated backup file (created through SQLyog or through mysqldump) to the person who has access and he will upload the file.
Here is the SQLyog's documentation for taking Backup. Select Databases and Tables that you want to backup through wizard.
Hope it helps....