0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[MySQL]コマンドラインからMySQLに接続した後、用意したSQLファイルを実行する方法

Last updated at Posted at 2019-06-13

本記事の説明

コマンドラインからMySQLに接続して、接続中に用意したSQLファイルを実行する手順を記載します。
本記事では、SQLファイルの用意から、MySQLの接続、SQLファイルの実行までの手順まで説明します。

SQLファイルの用意

実行したいSQLファイルを用意します。

vi hoge.sql

MySQLに接続

mysql -u ユーザー名 -D データベース名 -p

SQLファイルの実行

以下のコマンドで実行します。
結果がコマンドラインに出力されます。

mysql> source hoge.sql

SQLファイルはMySQLログインしたディレクトリに配置すれば実行されます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?