使用.SQL文件创建MySQL数据库 [英] Create MySQL Database with .SQL File

查看:346
本文介绍了使用.SQL文件创建MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MySQL一点也不了解.但是我试图使用Visio对MySQL数据库进行反向工程.我知道我应该采取什么步骤,但是我无法在数据库"部分显示数据库(如下所示):

I don't know much about MySQL at all. But I am trying to reverse engineer a MySQL database using Visio. I know what steps I should take to do this, but I can't get my database to show in the 'Databases' section (as below):

如何使用.SQL文件创建MySQL数据库并将其显示在此列表中?我已经试过这段代码: mysql -u用户名-p密码database_name<文件名 当然使用我自己的凭据.但这似乎不起作用.如果此语句有效,应将.SQL文件放在哪个文件夹中?

How do I create the MySQL database using the .SQL file and get it to show up in this list? I have tried this code: mysql -u username -p password database_name < filename.sql using my own credentials of course. But that doesn't seem to work. In what folder should the .SQL file be placed if this statement is to work?

推荐答案

1)创建文件"filename.sql"

1) Create a file "filename.sql"

2)在数据库中创建一个要在其中导入此文件的数据库.

2) Create a database in your DB in which you want to import this file.

3)从命令提示符/终端,移至创建"filename.sql"的目录.

3) From command-prompt/terminal, move to the directory where you have created a "filename.sql".

4)运行命令:mysql -u username -p password database_name < filename.sql. (您也可以提供文件的正确路径,然后从任何地方运行此命令).您可能没有为MySQL设置密码的情况.如果是这样,mysql -u username database_name < filename.sql也将起作用.

4) Run the command: mysql -u username -p password database_name < filename.sql. (You can also give the proper path of your file and run this command from anywhere). It might be the case that you don't have a password set for MySQL. If so, mysql -u username database_name < filename.sql will also work.

在您的情况下,如果您在 C:驱动器中创建了名称为 ojs 的数据库,并且还创建了名称为 ojs.sql 的文件然后运行以下命令:

In your case if you have created a database with name ojs and also created a file with name ojs.sql in C: drive then run the following command:

.将路径放在引号内.

Put the path inside quotes.

mysql -u username -p password ojs < "C:\ojs.sql"

还有另一种在mysql中导入表的方法.您也可以这样操作:

There is another way of importing tables in mysql. You can do it this way as well:

1)连接数据库

2)输入命令"use ojs;"

2) Type command "use ojs;"

3)键入命令源C:/ojs.sql"

3) Type command "source C:/ojs.sql"

这篇关于使用.SQL文件创建MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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