How to import mysql dump to SQLyog - mysql

I have few sql dump files like the tables taken from other db. Now i want to update the tables into my server using the sqlyog. So can anyone help me out in importing .sql files into the SQLyog ???
Thank u in advance

In SQLyog there is an option - Tools -> Execute SQL script. You can use this to run SQL scripts.

In order to make it clear please refer the screenshot:

Why use SQLYog, mysqldump is already an available command with server.
mysqldump --opt --user=username --password database > dumbfile.sql
where dumbfile will be your sql file.
MYSQLDump command I have used it a lot to get databases export and is highly reliable.
And mysql command to import the same:
mysql -u root -p[root_password] [database_name] < dumpfilename.sql

In SQLyog there is an option - Tools -> Execute SQL script. If there are some Errors it will give you a pop up, then click on the "Open Error File button", it will give you error in the sql file.

I think you can open your SQL file in Query window, and just run it in SQLYog. Have a look at this documentation page - Executing SQL Queries.
Also, you can use mysql — The MySQL Command-Line Tool, or dbForge Studio for MySQL (free express edition) to execute SQL files against the MySQL database.

In SQLyog v7.14, run DB -> Restore from SQL Dump..., or just press Ctrl+Shift+Q.

Related

Connecting MySQL with downloaded sample database

I've downloaded sample database, which is currently in my Downloads folder. How to connect it with MySQL console so I could test some queries?
Every tutorial I've seen so far is about how to make your own database and then test queries.
I assume you are talking about the "employees" sample?
That is a (zipped) SQL file, which you can load into MySQL by running
mysql < employees.sql
After unzipping. Eventully you also have to provide -u root as username and -p so it asks for a password.
If you use a GUI like MySQL WorkBench it has a menu entry to import SQL scripts.
See also https://dev.mysql.com/doc/employee/en/employees-installation.html and
https://dev.mysql.com/doc/refman/8.0/en/mysql.html

upload large database file to the server

I have 5GB database that needs to be uploaded to phpmyadmin and that too on the shared server where i cannot access the shell.Is there any solution that can take lesser time to upload? Please do help me by providing the steps to upload the sql file. I have searched through internet but could not find an answer.
Do not use phpmyadmin.
Assuming you have shell, upload the file and feed it directly to mysql command.
Your shell command will look like:
cat file.sql | mysql -uuser -ppassword database
or you can do gzipped file:
zcat file.sql.gz | mysql -uuser -ppassword database
Prior doing this check:
database connection works (correct database, user and password)
database is empty :)
mysql max packet size is OK
you have enough diskspace
* UPDATE *
You said you do not have shell access.
Then you have following options -
upload the file and contact support, let they do it for you.
feed it remote, cpanel have special menu where you can get remove access, other panels have same ability too.
in this case code will be executed on your computer and look like:
cat file.sql | mysql -uroot -phipopodil -hwebsite.com
or for windows:
/path/to/mysql -uroot -phipopodil -hwebsite.com < file.sql
do some "hack" - feed it through crontab, at or via php system() command.
If you choose "hack" option, note following:
php have max_execution_time - even if you set it to zero, there could be some limit "imposed" from hosting.
usually hosts have limited mysql updates per hour.
there could be some ulimit restrictions.
if you execute feeding of 5 GB on shared server, server will slow down and administrator will check what you are doing.
This depends on your database, you tagged it with 3 different database types, mysql, sql-server, and postgresql. I know mysql and postgresql have import features, although I'd be surprised if SQL Server didn't as well. You could import the database file via the command line instead of having to use phpmyadmin.
Incidentally, the phpmyadmin tool also has an import feature, but that again depends on the format of your database. If it's a compatible sql file, you could upload it to phpmyadmin and import it there, but I'd recommend the previous method I mentioned, upload it to your host, then use whatever database tool (mysqlimport for mysql, or if it's the result of a pg_dump command, you can just run:
psql <dbname> < <yourfile>
ie
psql mydatabase < inputfile.sql

Importing sql file into Mysql running xampp using commandline in Mac

I have installed xampp in my macosx and i want to import the wordnet sql file its not working. i tried this command
/Applications/XAMPP/xamppfiles/bin/mysql -u root -p dict < wordnet20-from-prolog-all-3.mysql
The commandline works without any errors takes a while to finish.
I fireup phpmyadmin and check the dict database and nothing is there. What is the problem?
In your .sql file, look for a USE statement that would switch execution to another database. It might explain why you see nothing in the database used on the command line.

Series of SQL/DML/DDL commands and Syntax for running in DBMS

This is a small question, but what is the name for a series of SQL/ DML / DDL commands stored in a file? Also, what is the syntax for running this file in DBMS?
The help command in mysql refers to it as a SQL script file. The syntax for running it in MySQL from the shell is:
mysql ..options.. < filename
e.g.
mysql -u username -p databasename < filename.sql
See the MySQL documentation for details of using the mysql command-line tool.
You can also run it from within the mysql command with:
mysql>source filename
or
mysql>. filename
I don't use phpMyAdmin, so I don't know if there's a way to do it from there.

Importing using MySQL WorkBench... error ERROR 1046 (3D000)

Scenario: building a RoR enviroment locally for development. Production is on EngineYard / GitHub. All now working ok, except DB isn't importing.
I have a .sql file that i've taken from my prod EY site. Now i need to import it to my MySQL locally. I'm using Workbench (as i'm new to this), but getting error below.
Please help?
08:07:43 Restoring /home/james/Downloads/Futology.sql Running: mysql
--defaults-extra-file="/tmp/tmpAVeE58/extraparams.cnf" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "/home/james/Downloads/Futology.sql" ERROR 1046 (3D000) at line 22: No database selected
Operation failed with exitcode 1 08:07:43 Import of
/home/james/Downloads/Futology.sql has finished with 1 errors
Workbench doesn't know the database (schema) you want to use.
In workbench, when using Data Import/Restore, just below where you choose the file to import, it asks "Default Schema to be Imported To"
Just choose the database (schema) you want it to use from the dropdown titled Default Target Schema. If you don't have a database (schema) already, you can create it with the "New" button.
This is confusing because MySQL generally seems to use the term database but Workbench uses schema. They mean the same thing for most purposes. MySQL 'create schema' and 'create database' - Is there any difference
Not used Workbench too much however it's easy enough to do from command line have a look at this (below phpMyAdmin instructions)
The command you're after is:
mysql -u #username# -p #database# < #dump_file#
Simply by choosing your target schema
As I circled in above image
Similar to brynn's answer, simply modify your SQL file and insert the following line at the very top:
use yourdatabasename
Replacing yourdatabasename with the database into which you are trying to import. Also, this database should already be created (albeit empty) before you import into it.
Here's another option that worked for me. I'm using MySQL 5.5 on a VM I set up for importing a large MySQL .sql dump that contained: 1). a create table statement 2). insert statements for inserting a large amount of data into the table.
at the MySQL command line client prompt type:
use yourdatabasename
source d:\yourpath\yourfilename.sql
for more info on the 'source' and other commands, enter ? at the prompt.
The above command line is correct. I found I have to do this when importing .sql files from older versions of MySQL. I also found I had to edit the .sql file (top of the file) and set the db name to be the same as the blank db you create before doing the import.