faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

37 of 45 people (82%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Database: MySql: Command: File: Source: Read: How to: How to read commands from a file? [batch]

May 2nd, 2008 21:50
dman, Knud van Eeden, http://sturly.com


----------------------------------------------------------------------
--- Knud van Eeden --- 10 April 2021 - 07:04 pm ----------------------
Database: MySql: Command: File: Source: Read: How to: How to read 
commands from a file? [batch]
---
Steps: Overview:
 1. -Create a text file containing your commands
     (you will not see the SQL query text while they are executed)
     e.g.
--- cut here: begin --------------------------------------------------
CREATE DATABASE databaseTest;
USE databaseTest;
CREATE TABLE
 tableCustomer
(
 columnId INT NOT NULL PRIMARY KEY,
 columnName VARCHAR( 50 )
)
;
INSERT INTO
 tableCustomer
(
 columnName
)
VALUES
(
 "Knud"
)
;
--- cut here: end ----------------------------------------------------
 2. -Save this file in the 'bin' directory of MySql
      e.g.
       mysourcefile.txt
 3. -Goto the 'bin' directory of MySql
 4. -Run the program
      mysql.exe
 5. -Type the command
      source <your filename>
      ---
       e.g.
        source mysourcefile.txt;
---
---
Note:
If you create the file after you started
MySql, you will have to restart mysql.exe
(otherwise error
 'Failed to open file '...', error: 2')
---
---
Internet: see also:
---
Database: MySql: Command: Multiple: Execute: How to execute multiple 
commands at once in MySql?
http://www.faqts.com/knowledge_base/view.phtml/aid/36416/fid/52
----------------------------------------------------------------------