MySQL Serverへ接続後の基本的な操作

  • 投稿日:
  • by
  • カテゴリ:

■ホストとユーザ一覧の確認
mysql> select host,user from mysql.user;
+--------------------------+------+
| host | user |
+--------------------------+------+
| 127.0.0.1 | root |
| localhost | |
| localhost | root |
| rag45s1vm007.ranonet.net | |
| rag45s1vm007.ranonet.net | root |
+--------------------------+------+
5 rows in set (0.00 sec)


■ユーザのパスワード変更
mysql> set password for root@"ホスト名"=password('新パスワード');

Query OK, 0 rows affected (0.00 sec)


■データベース一覧を表示
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)


■データベースの切り替え
mysql> use データベース名;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed


■テーブル一覧を表示
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| proc |
| procs_priv |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
17 rows in set (0.00 sec)