I have a database in MySQL which can be accessed using Microsoft SQL Server Management Studios. I have a .bak file of that database and I want to shift this database to Postgres.
I went to the command line and I opened the directory of my Postgres to the bin folder from the program files, and I wrote the command :
psql -U postgres -d postgres < (directory of the .bak file)'
I got the following error on running the above command:
ERROR: syntax error at or near "TAPE"
LINE 1: TAPE
Can someone please explain why I am getting this error and how to resolve it?
Related
I am using mysqlsh to connect to mysql database running in docker container.
I can source sql file using sql; but can not source exactly same file using mysqlsh.
I googled for the solution yet to find the one.
Trying to import a very large database file.
Windows Apache PhpMyAdmin.
USE test;
source somefil.sql;
I get a syntax error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source somefil.sql' at line 1 "
There is no such command in mysql server as source. This command is specific to mysql own command line client, which is also named mysql, therefore it is not available in phpmyadmin.
Copy-paste the contents of the sql file into the command window of phpmyadmin and execute its contents directly from there. You may have to increase the php max execution time parameter, if the import file is truly big.
However, I would use the command line client to execute a really big sql file because phpmyadmin is not suitable for that.
to restor backup of my datebase I use command like that
from your os command promt :
mysql -u youruser -p yourdatabasename < yourfilewithfullpath.sql
Actually source command is used from command prompt so Use below steps-
Go to command prompt-
connect mysql
now use below command-
source d:/backup/somefil.sql;
I have a .sql file on windows that I want to run on mysql server that is present on centOS. I am using the following command to connect and execute the .sql file-
mysql -u user_name -ppassw0rd -h [ip address of centOS] -P [port used
by mysql server] --verbose < file path on windows.
But on executing this command i am getting an error as :
ERROR 2013 (HY000) at line 3: Lost connection to MySQL server during
query
Also is there any way to see the errors that occur when query is executed.
Note - I am using mysql command line tool on windows to run the above command.
I created a data base using mysql. I used MySQLDump to create one database backup file in text format (MySql 5.5 on Windows XP). The database is local on my machine (local host).
I am having trouble using the MySQL command to load the dump file to restore the database. I have done the following:
Research stack overflow for how to do it. I noticed there's a bug using the MySQL command to restore the data from a post. Before I run the command, I DROP the database and CREATE the database using MySQL workbench.
I type the following command in the DOS prompt to restore the database:
mysql -u root -p -h localhost -D matlab_data -o < backup.sql
backup.sql is a the backup file in text format created by MySqlDump.
I am then asked for the password which I enter. I get the DOS prompt right away with no error message. I've waited several hours for the command to run and the database is still empty.
I have tried various command formats over the last few days. If I enter incorrect data in the command line (non existen file, database, etc), I get an error message.
I feel I would not see the DOS prompt until the database is restored. If I don't DROP and CREATE the database, I get an error message. Otherwise, not.
Does anybody have any idea what the issue is? I realize that I could be making a stupid mistake.
Thank you for your help.
shell into the mysql console and run the sql file as this
If you are already running mysql, you can execute an SQL script file using the source command or . command:
mysql> source file_name
mysql> \. file_name
note that file_name must be an absolut path
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.