Home Database Mysql Tutorial mysql命令行导入sql文件到指定数据库的方法

mysql命令行导入sql文件到指定数据库的方法

Jun 07, 2016 pm 03:15 PM
mysql sql Command Line import designation database document method

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 第四章: ls 有一些我们常用的参数, 比如我们要知道当前目录的所有内容, 包括隐藏文件夹和文件和所有属性, 例 [root@AY130410135131135089 logs]# ls boot2013-06.log 使用 ls 命令的“-l”选项,则

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

 

  第四章:

  ls 有一些我们常用的参数, 比如我们要知道当前目录的所有内容, 包括隐藏文件夹和文件和所有属性, 例

  [root@AY130410135131135089 logs]# ls

  boot2013-06.log

  使用 ls 命令的“-l”选项,则结果以长模式输出:

  [root@AY130410135131135089 logs]# ls -l

  total 8

  -rw-rw-rw- 1 root root 5975 Jun 15 17:34 boot2013-06.log

  显示隐藏文件:

  [root@AY130410135131135089 logs]# ls -a

  . .. boot2013-06.log

  命令 选项 参数

  command -options arguments

  下面这个例子,ls 命令有两个选项, “l” 选项产生长格式输出,“t”选项按文件修改时间的先后来排序。

  [me@linuxbox ~]$ ls -lt

  确定一个文件什么文件类型我们用 file, 使用方法如下

  [root@AY130410135131135089 logs]# file boot2013-06.log

  boot2013-06.log: ASCII text

  [root@AY130410135131135089 assets]# file world.swf

  world.swf: Macromedia Flash data (compressed), version 10

  用 less 浏览文件内容

  [me@linuxbox ~]$ less /etc/passwd

  TODO 表 4-3: less 命令 需要截图哦。

  小提示:记得复制和粘贴技巧!如果你正在使用鼠标,双击文件名,来复制它,然后按下鼠标中键,粘贴文件名到命令行中。

  Symbolic Links符号链接

  Hard Links硬链接

  第五章:操作文件和目录

  cp ― 复制文件和目录

  mv ― 移动/重命名文件和目录

  mkdir ― 创建目录

  rm ― 删除文件和目录

  ln ― 创建硬链接和符号链接 TODO没搞懂 和Window快捷键的区别联系 点击打开链接

  cp ― 复制文件和目录

  jiangge@localhost:~$ cp item1 item2 # 把item复制到directory目录

  jiangge@localhost:~$ cp file1 file2 # 复制file1到file2

  jiangge@localhost:~$ cp -i file1 file2 # 复制过程中如果有这个文件提示是否覆盖

  jiangge@localhost:~$ cp dir1/* dir2 # 复制目录下所有文件或目录到目标目录

  jiangge@localhost:~$ cp -r dir1 dir2 # 递归复制

  mkdir ― 创建目录

  jiangge@localhost:~$ mkdir dir

  jiangge@localhost:~$ mkdir dir1 dir2 dir3 # 创建多个文件夹

  jiangge@localhost:~$ mkdir -p /dir1/dir2/dir3 # 递归创建文件夹

  mv ― 移动/重命名文件和目录

  jiangge@localhost:~$ mv file1 file2 # 重命名

  jiangge@localhost:~$ mv -i file1 file2 # 如果存在提示是否写入

  jiangge@localhost:~$ mv file1 file2 dir1 # 移动 file1 file2 至 dir1

  jiangge@localhost:~$ mv dir1 dir2 # 移动 dir1 至 dir2

  rm ― 删除文件和目录

  jiangge@localhost:~$ rm file1

  jiangge@localhost:~$ rm file1 dir1

  jiangge@localhost:~$ rm -r dir1 #删除文件夹, 递归删除

  jiangge@localhost:~$ rm -rf dir1 强制删除

  表5-3:通配符范例

  模式 匹配对象

  * 所有文件

  g* 文件名以“g”开头的文件

  b*.txt 以"b"开头,中间有零个或任意多个字符,并以".txt"结尾的文件

  Data??? 以“Data”开头,其后紧接着3个字符的文件

  [abc]* 文件名以"a","b",或"c"开头的文件

  BACKUP.[0-9][0-9][0-9] 以"BACKUP."开头,并紧接着3个数字的文件

  [[:upper:]]* 以大写字母开头的文件

  [![:digit:]]* 不以数字开头的文件

  *[[:lower:]123] 文件名以小写字母结尾,或以 “1”,“2”,或 “3” 结尾的文件

  表5-4:cp 选项

  选项 意义

  -a, --archive 复制文件和目录,以及它们的属性,包括所有权和权限。 通常,复本具有用户所操作文件的默认属性。

  -i, --interactive 在重写已存在文件之前,提示用户确认。如果这个选项不指定, cp 命令会默认重写文件。

  -r, --recursive 递归地复制目录及目录中的内容。当复制目录时, 需要这个选项(或者-a 选项)。

  -u, --update 当把文件从一个目录复制到另一个目录时,仅复制 目标目录中不存在的文件,或者是文件内容新于目标目录中已经存在的文件。

  -v, --verbose 显示翔实的命令操作信息

  表 5―5: cp 实例

  命令 运行结果

  cp file1 file2 复制文件 file1内容到文件 file2。如果 file2已经存在,file2的内容会被 file1的 内容重写。如果 file2不存在,则会创建 file2。

  cp -i file1 file2 这条命令和上面的命令一样,除了如果文件 file2存在的话,在文件 file2被重写之前, 会提示用户确认信息。

  cp file1 file2 dir1 复制文件 file1和文件 file2到目录 dir1。目录 dir1必须存在。

  cp dir1/* dir2 使用一个通配符,在目录 dir1中的所有文件都被复制到目录 dir2中。 dir2必须已经存在。

  cp -r dir1 dir2 复制目录 dir1中的内容到目录 dir2。如果目录 dir2不存在, 创建目录 dir2,操作完成后,目录 dir2中的内容和 dir1中的一样。 如果目录 dir2存在,则目录 dir1(和目录中的内容)将会被复制到 dir2中。

  第六章:点击打开链接

  type - 解读一个命令

  which - 显示哪些是可执行程序,which 确定一个可执行程序的位置

  man - 显示命令手册

  apropos - 显示一个合适的命令列表

  info - 显示一个命令信息

  whatis - 显示非常简短的描述一个命令

  alias - 为命令创建一个别名

  [shijiangge@localhost test]$ type type

  type is a shell builtin

  [shijiangge@localhost test]$ type ls

  ls is aliased to `ls --color=tty'

  [shijiangge@localhost test]$ type cp

  cp is hashed (/bin/cp)

  [shijiangge@localhost test]$ which ls #which 确定一个可执行程序的位置

  alias ls='ls --color=tty'

  /bin/ls

  [shijiangge@localhost test]$ which vim

  /usr/bin/vim

  help 获得帮助信息, 在每个shell命令的后面加上--help参数, 如

  [shijiangge@localhost test]$ ls --help

  Usage: ls [OPTION]... [FILE]...

  List information about the FILEs (the current directory by default).

  Sort entries alphabetically if none of -cftuvSUX nor --sort.

  [shijiangge@localhost test]$ help cd

  cd: cd [-L|-P] [dir]

  Change the current directory to DIR. The variable $HOME is the

  default DIR.

  [1] [2] [3] 

mysql命令行导入sql文件到指定数据库的方法

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1267
29
C# Tutorial
1239
24
MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

Redis: Understanding Its Architecture and Purpose Redis: Understanding Its Architecture and Purpose Apr 26, 2025 am 12:11 AM

Redis is a memory data structure storage system, mainly used as a database, cache and message broker. Its core features include single-threaded model, I/O multiplexing, persistence mechanism, replication and clustering functions. Redis is commonly used in practical applications for caching, session storage, and message queues. It can significantly improve its performance by selecting the right data structure, using pipelines and transactions, and monitoring and tuning.

How does MySQL differ from Oracle? How does MySQL differ from Oracle? Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

See all articles