I was trying to upload an .sql file to mysql console with \. but it throwed me:
mysql> \. /home/krest/s.sql;
ERROR:
Failed to open file '/home/krest/s.sql;', error: 2
However, "source" command works properly!
What I am doing wrong?
I am running console through ubuntu 14.04 terminal.
Look closer to the error message, everything you need to know is there:
Failed to open file '/home/krest/s.sql;', error: 2
Error 2 is "No such file or directory". You can use the perror command line tool to find out the message from an error code returned by MySQL.
Did you figure out what's wrong? The semicolon after the file name is not supposed to be there. MySQL thinks it is part of the file name and this is why it cannot find the file.
As a side note, it seems that some of the short commands work if the ending semicolon is preceded by a space and do not work without the space (\u, for example, works this way). Others take everything until the end of line as parameter (and fail with an error because of the ending semicolon).
Related
I'm trying to move data from SQL Server to MariaDB using MySQL Workbench.
I installed it as 8.0.27 version at first, and after the problem occurred, I downgraded it to 8.0.26 version, but the problem was not solved.
I'm confused whether it's a problem with the data you're trying to move or something that's happening in MySQL Workbench.
I tried googling, but there was a similar phenomenon, but I couldn't find an answer.
https://bugs.mysql.com/bug.php?id=105772
Can you give me some advice?
thanks you.
------------------------------------------------------------------ Starting... Create Script File...
Traceback (most recent call last): File "C:\Program
Files\MySQL\MySQL Workbench 8.0
CE\workbench\wizard_progress_page_widget.py", line 71, in run
self.func() File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\migration_schema_creation.py", line 188, in
_create_script_task
self.main.plan.createTargetScript(self.main.plan.state.objectCreationParams["CreateSQLFile"])
File "C:\Program Files\MySQL\MySQL Workbench 8.0
CE\modules\migration.py", line 527, in createTargetScript
grt.modules.DbMySQLFE.createScriptForCatalogObjects(path, self.migrationTarget.catalog, self.state.objectCreationParams)
SystemError: UnicodeEncodeError("'charmap' codec can't encode
characters in position 99-104: character maps to "): error
calling Python module function DbMySQLFE.createScriptForCatalogObjects
ERROR: Error during Create Script File: UnicodeEncodeError("'charmap'
codec can't encode characters in position 99-104: character maps to
"): error calling Python module function
DbMySQLFE.createScriptForCatalogObjects ERROR: Exception in task
'Create Script File': SystemError('UnicodeEncodeError("'charmap'
codec can't encode characters in position 99-104: character maps to
"): error calling Python module function
DbMySQLFE.createScriptForCatalogObjects')
Failed
enter image description here
If you are seeing \uFFFD, that is the REPLACEMENT CHARACTER - - �
It means that the data was already corrupted beyond repair. Go back a step in the process of the data to see what first led to it.
See also "black diamond" in Trouble with UTF-8 characters; what I see is not what I stored to find some ways that it can occur purely in MySQL. However, it sounds like SQL Server created it; I think the problem is back there.
Fetch the hex for any characters involved, noting that \uFFDD (UTF-8 hex: EFBFBD) is after things are already corrupted.
In UTF-8 (MySQL's utf8 or utf8mb4), Hex EAB0zz through ED9Ezz is used for Hangul (Korean). For example, 박상우 is hex EBB095 EC8381 EC9AB0 (minus the spaces).
I'm trying to import a MySQL Database via command line (Terminal). The file's path seems to be correct, but I keep getting an error message that is most likely showing that, the path of the SQL file I'm importing is not correct. Below is the sample of the command line I'm using and the error I'm getting...
NOTE: Linux Server, Centos 7 - MariaDB
source C:/Users/localcomputerUser/SQLFileFolder/SQLFile.sql
source C:/Users/localcomputerUser/SQLFileFolder/SQLFile.sql
Failed to open file 'C:/Users/localcomputerUser/SQLFileFolder/SQLFile.sql
', error: 2
Thanks for your support.
I have a file that is filled with statements that appear like the following:
update table set column1=NULL where column2 in (select id from users where user_id in ('user1','user2'));
As you can see this is correct syntax. When I run this command manually on the mysql command line it works as intended.
However when I attempt to source the file I get syntax errors. Has anyone seen this issue before? I'm looking for a resolution...
mysql> \! source /tmp/update_users.sql
/tmp/update_users.sql: line 2: syntax error near unexpected token `('
/tmp/update_users.sql: line 2: `(select id from users where user_id in ('user1','user2'));'
You have to use the MySQL source command:
mysql> source /tmp/update_users.sql
When you use \!, you instead invoke a shell command. The shell source command expects a shell script, not a sql file.
hi i am using windows 7, xampp
. i am trying to run a sql file using CMD ut it gives me an error
ERROR:
Unknown command '\x'.
this is what i am doing
this command is not working
mysql> SOURCE C:\xampp\htdocs\elephanti2\db\mas_gis_city_ip.sql;
*** one other problem with this works fine when i tried by go to phpmyadmin and import the file .
why this happening , i have no idea , please help ..................
My original answer:
mysql> SOURCE C:\\xampp\\htdocs\\elephanti2\\db\\mas_gis_city_ip.sql;
You could also try executing the command like this:
mysql> SOURCE C:/xampp/htdocs/elephanti2/db/mas_gis_city_ip.sql;
(Source: a comment in the reference manual suggests using forward slashes on Windows machines)
Try quoting your file name. Notice your command:
mysql> SOURCE C:\xampp\htdocs...
is probably being interpreted as:
mysql SOURCE C: \xampp \htdocs...
(see the \x there?)
If you quote the file name, I bet it'll work. (not sure if mysql requires ' or " for quoting filenames in this context, try both)
Actually this worked. I think it is dwuff's previous answer.
mysql> SOURCE C:\\xampp\\htdocs\\elephanti2\\db\\mas_gis_city_ip.sql;
I had the same problem recently trying to install FossTrak, and this was the syntax that worked on windows 10, with Mysql 5.7
\. C:/share/epcis-repository-0.5.0/epcis_schema.sql
using \source did not, and neither did \\, and by accident i removed the ; and it worked.
I have a .sql file on my computer at C:\Users\Owner\Documents\file.sql
(Windows Vista) that just creates a database and a simple table within.
In mysql at the command line i enter
source C:\Users\Owner\Documents\newbie.sql;
the query seems to work ok but just before it shows me the successfully created table it outputs the following errors that seem to be related to how i entered the file name:
ERROR:
Unknown command '\U'.
ERROR:
Unknown command '\O'.
ERROR:
Unknown command '\D'.
ERROR:
Unknown command '\n'.
Pardon the newbie error...whats the fix?
Thanks!
Try using forward slash / in place of back slash \ in file path:
C:/Users/Owner/Documents/newbie.sql
or put it between double quotes (")