I am new to database and have just started to learn MYSQL. I have downloaded a sql file called rating.sql and would like to import it to the MYSQL database installed on the local machine. The operation system is Windows 7. The path for the sql file is:
"E:\rating.sql".
I am using the following commands in the MySQL Command Line Client
mysql>use database_name;
mysql>source E:\rating.sql;
The system gives the following error message:
ERROR 1049 <42000>: Unknown database 'ating.sql'
It is definitely something related to the path. Can anyone explain how this error is generated?Thanks
You have use \ and this is an escape character (omits the immediate following character. So to fix this you can use \ instead.
mysql>resour E:\\rating.sql;
Mysql recognises \r as an escape for a carriage return character.
To make it simpler, could you rename your file to something beginning with another letter...mustn't be b n r t or z...
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).
After a clean install of Windows 10 when I started to use MySQL workbench I have this error when I try to dump a database.
I could not find anything about it anywhere, the only thing I find are problems with phyton, but nothing related with Workbench.
Output after dumping a database:
08:29:00 Dumping foo(all tables)
Error executing task write() argument must be str, not bytes
08:29:01 Export of b'C:\\Users\\erick\\Documents\\dumps\\Dump20210121 (2).sql' has finished
And the output file is in blank, some ideas?
You can disable (uncheck) the option create schema. It is annoying but it works.
If you have the latest MySQL Workbench (8.0.23), just uninstall and install MySQL Workbench 8.0.20. That worked for me.
Another workaround to this issue is to edit wb_admin_export.py.
In dump_to_folder (line 1679) replace
self.out_pipe = open(path,"w")
with
self.out_pipe = open(path,"wb")
In dump_to_file (line 1957) replace
self.out_pipe = open(self.path,"w")
with
self.out_pipe = open(self.path,"wb")
If you a using version 8.0.23, update to 8.0.25 or above.... it will fix this issue
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 (")