如何在MySQL中运行SQL脚本? [英] How to run SQL script in MySQL?

查看:98
本文介绍了如何在MySQL中运行SQL脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MySQL中执行一个包含SQL查询的文本文件.

I want to execute a text file containing SQL queries, in MySQL.

我尝试运行source /Desktop/test.sql并收到错误:

I tried to run source /Desktop/test.sql and received the error:

mysql>. \ home \ sivakumar \ Desktop \ test.sql错误:无法打开文件 '\ home \ sivakumar \ Desktop \ test.sql',错误:2

mysql> . \home\sivakumar\Desktop\test.sql ERROR: Failed to open file '\home\sivakumar\Desktop\test.sql', error: 2

关于我在做什么错的任何想法吗?

Any idea on what I am doing wrong?

推荐答案

如果您使用的是MySQL命令行mysql>,则必须将SQL文件声明为source.

If you’re at the MySQL command line mysql> you have to declare the SQL file as source.

mysql> source \home\user\Desktop\test.sql;

这篇关于如何在MySQL中运行SQL脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆