MariaDB 10.6にコマンドの引数で使用するデータベースを指定する

2022年1月23日

環境
Windows 10 64bit
MariaDB 10.6.4

書式
mariadb -u root -p データベース名

使用例
1.MariaDB に接続したあとで testdb データベースを選択するには次のように実行します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
C:\>mariadb -u root -p testdb
Enter password: *********    #パスワード入力
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.6.4-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [testdb]>
C:\>mariadb -u root -p testdb Enter password: *********    #パスワード入力 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.6.4-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [testdb]>
C:\>mariadb -u root -p testdb
Enter password: *********    #パスワード入力
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.6.4-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [testdb]>

2.使用しているデータベースを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [testdb]> select database();
+------------+
| database() |
+------------+
| testdb |
+------------+
1 row in set (0.000 sec)
MariaDB [testdb]> select database(); +------------+ | database() | +------------+ | testdb | +------------+ 1 row in set (0.000 sec)
MariaDB [testdb]> select database();
+------------+
| database() |
+------------+
| testdb     |
+------------+
1 row in set (0.000 sec)

 

MariaDB

Posted by arkgame