问题描述:

I am trying to load a text (.sql) file into a MySQL database on Windows 2008 R2, using localhost, but getting an odd error where the first letter of the database name is getting truncated. I first do 'show databases' to confirm I'm in and the strings are correct, then change to the target database, then run 'Load E:\MySQL\rosedestinationlog.sql;

To avoid any ambiguity, I am logging in as root.

That returns the weird error 1049 followed by the name of the database with the first character missing. If I then try to do anything else, such as running 'show databases' again, I get an error that the connection is lost. Exiting the CL and re-starting it allows me to re-connect, but with the same errors after that.

I've opened port 3006 in both directions to TCP. I can source some other files, but others hit the same errors. I can load these files without problem on a Mac. Below is the CL screen printout:

Windows PowerShell

Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> mysql -u root -p;

Enter password: *******

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 61

Server version: 5.5.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| akhf_beta |

| bank |

| mysql |

| performance_schema |

| rosecampdiary |

| rosedestinationlog |

| roseflightprep |

| ruredb |

| test |

+--------------------+

10 rows in set (0.00 sec)

mysql> use rosedestinationlog;

Database changed

mysql> source E:\MySQL\rosedestinationlog.sql;

ERROR:

Unknown command '\M'.

ERROR 1049 (42000): Unknown database 'osedestinationlog.sql;'

mysql> show databases;

No connection. Trying to reconnect...

ERROR 1049 (42000): Unknown database 'osedestinationlog.sql;'

ERROR:

Can't connect to the server

mysql>

网友答案:

When you're running:

mysql> source E:\MySQL\rosedestinationlog.sql;

It looks like the the backslash-M is being picked up by the program. Try putting the file path all in quotes e.g. something like:

mysql> source 'E:\MySQL\rosedestinationlog.sql';
网友答案:
mysql> use rosedestinationlog < source "E:\MySQL\rosedestinationlog.sql";

If your source .sql file contains statement to create database 'rosedestinationlog' remove it and try it will work.

相关阅读:
Top