我写了两行插入语句
存放在了2.sql文件里(放在了桌面)
在mysql命令行中使用source 2.sql 出错
想要执行2.sql该怎么去做
我的是xp系统 还有一种方法是在系统的命令行里 如何去做(这个可以不回 呵~)
多谢高手指教
分少新人 谢谢
存放在了2.sql文件里(放在了桌面)
在mysql命令行中使用source 2.sql 出错
想要执行2.sql该怎么去做
我的是xp系统 还有一种方法是在系统的命令行里 如何去做(这个可以不回 呵~)
多谢高手指教
分少新人 谢谢
Database changed
mysql> source C:/2.sql;
+----+-------------+--------+
| ID | adStyleName | isUsed |
+----+-------------+--------+
| 1 | 全屏广告 | 1 |
| 2 | 对联广告 | 1 |
+----+-------------+--------+
2 rows in set (0.00 sec)
可以阿,要完整路径,用'/'这种斜杠
+----+-------------+--------+
| ID | adStyleName | isUsed |
+----+-------------+--------+
| 1 | 全屏广告 | 1 |
| 2 | 对联广告 | 1 |
+----+-------------+--------+
2 rows in set (0.00 sec)
第一种
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| testtable |
+----------------+
1 row in set (0.00 sec)mysql> select * from testtable;
+----+-------------------------+
| id | t_str |
+----+-------------------------+
| 1 | test1,test2,test3,test4 |
| 2 | test2,test3,test4 |
| 3 | test3,test4 |
| 4 | test4 |
+----+-------------------------+
4 rows in set (0.00 sec)mysql> \q
ByeC:\>mysqldump -uroot -p --add-drop-table --tables test testtable>c:\\testtable.sql
Enter password: ******C:\>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1311
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use test
Database changed
mysql> truncate table testtable;
Query OK, 4 rows affected (0.02 sec)mysql> select * from testtable;
Empty set (0.00 sec)mysql> source c:\\testtable.sql
Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)mysql> select * from testtable;
+----+-------------------------+
| id | t_str |
+----+-------------------------+
| 1 | test1,test2,test3,test4 |
| 2 | test2,test3,test4 |
| 3 | test3,test4 |
| 4 | test4 |
+----+-------------------------+
4 rows in set (0.00 sec)
mysql> truncate table testtable;
Query OK, 4 rows affected (0.02 sec)第二种C:\>mysql -uroot -p -b test< c:\\testtable.sql
Enter password: ******C:\>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1314
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use test
Database changed
mysql> select * from testtable;
+----+-------------------------+
| id | t_str |
+----+-------------------------+
| 1 | test1,test2,test3,test4 |
| 2 | test2,test3,test4 |
| 3 | test3,test4 |
| 4 | test4 |
+----+-------------------------+
4 rows in set (0.00 sec)mysql>
windows:
右键"我的电脑"-"属性"-"高级"-"环境变量"
Linux:
whereis mysql 查看mysql安装的位置,没有的话需要安装
env 看看系统环境变量