0
0

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 3 years have passed since last update.

MySQLのコマンドラインからのデータベース指定方法

Last updated at Posted at 2020-10-08

MySQLにおいて、コマンドラインからデータベースを指定する方法について記述する。
ここで述べるデータベース指定方法は、下記3種類である。

shell> mysql -h host -u user -d database -p

もしくは、

shell> mysql -h host -u user -p database

-D オプションでは接続先のデータベース名を指定。
database にデータベース名を入力。
その他についての説明は、こちらで説明。

また、下記のようにdatabaseを指定しなかった場合は、後からuse文を使用することで、データベースを指定することが可能。

shell> mysql -h host -u user -p
Enter password:

︙ (途中省略)

MySQL [(none)]> use database;

問題なければ、最後に Database changed と表示されており、MySQL [(none)] が MySQL [データベース名] に切り替わっている。

[参考]http://mysql.javarou.com/dat/000389.html
[参考]https://dev.mysql.com/doc/refman/5.6/ja/connecting.html
[参考]https://www.dbonline.jp/mysql/database/index3.html

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?