ローカルの環境をサーバー側に反映させるために、やったメモです。
目次
バージョンを確認
mysql --version
結果
mysql Ver 15.1 Distrib 10.7.3-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
接続する(SQLが使える)
mysql -u root -p
結果
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 10.7.3-MariaDB-1:10.7.3+maria~focal-log 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 [(none)]>
データベースを表示(SQL)
show databases;
結果
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sampleapp_db |
| sys |
+--------------------+
5 rows in set (0.028 sec)
テーブルを表示(SQL)
show tables from sampleapp_db;
結果
+----------------------------+
| Tables_in_sampleapp_db |
+----------------------------+
| auth_group |
| auth_group_permissions |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| django_admin_log |
| django_content_type |
| django_migrations |
| django_session |
+----------------------------+
10 rows in set (0.026 sec)
テーブル作成(SQL)
create databaes hoge_table
結果
Query OK, 1 row affected (0.014 sec)
使うデータベースを選択する(SQL)
use hoge_table
結果
MariaDB [(none)]>
↓
Database changed
MariaDB [hoge_table]>
sqlファイルを取り込む (SQL)
source ./hoge.sql
結果
Query OK, 0 rows affected (0.000 sec)
終了する
exit
結果
Bye