Several methods to execute sql files under mysql command line

Several methods to execute sql files under mysql command line

To achieve the goal: Import the tsinfo180516.sql file into the database demo1 through the command line.

Rendering

The first method: When the MySQL database is not connected

Execute the sql file in the mysql command line

Run --cmd

C:\Users\lenovo>mysql -u account -p password -D database name < sql file absolute path

C:\Users\lenovo>mysql -uroot -proot -Ddemo1<C:\Users\lenovo\Desktop\tsinfo180516\tsinfo180516.sql

The second method: When the database is already connected, the command prompt is mysql>.

Enter the password to connect to the database

Practical record of importing SQL files using MySQL source command

Enter the full path of the source script or \. full path of the script

For example: source <C:\Users\lenovo\Desktop\tsinfo180516\tsinfo180516.sql

Or \. <C:\Users\lenovo\Desktop\tsinfo180516\tsinfo180516.sql

This concludes this article about several methods of executing SQL files under the MySQL command line. For more information about executing SQL files under the MySQL command line, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • mysql command line script execution example
  • Summary of several ways to execute SQL in the MySQL command line

<<:  Tutorial on installing nginx in Linux environment

>>:  Pure CSS to solve the ceiling and bottom suction in H5 layout implementation steps

Recommend

A quick guide to MySQL indexes

The establishment of MySQL index is very importan...

MySQL cursor detailed introduction

Table of contents 1. What is a cursor? 2. How to ...

JavaScript implements front-end countdown effect

This article shares the specific code of JavaScri...

MySQL joint index effective conditions and index invalid conditions

Table of contents 1. Conditions for joint index f...

3 common errors in reading MySQL Binlog logs

1. mysqlbinlog: [ERROR] unknown variable 'def...

InnoDB engine redo file maintenance method

If you want to adjust the size and number of Inno...

Detailed explanation of LVM seamless disk horizontal expansion based on Linux

environment name property CPU x5650 Memory 4G dis...

Tutorial on using iostat command in Linux

Preface It is said that if the people doing opera...

Solve the problem that Mysql5.7.17 fails to install and start under Windows

Install MySQL for the first time on your machine....

Several methods to solve the problem of MySQL fuzzy query index failure

When we use the like % wildcard, we often encount...

MySQL online log library migration example

Let me tell you about a recent case. A game log l...

Analysis of the solution to Nginx Session sharing problem

This article mainly introduces the solution to th...

A brief discussion on event-driven development in JS and Nodejs

Table of contents Event-driven and publish-subscr...