豚吐露@wiki
mysqlで良くやりたくなる操作
最終更新:
ohden
-
view
mysqlで良くやりたくなる操作
CentOS 6.4
MySQL 5.1.69
MySQL 5.1.69
- Version確認
①mysqlにlogin
# mysql -uroot -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.69-log Source distribution
②mysqlコマンド
# mysql --version
mysql Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (x86_64) using readline 5.1
- user一覧取得
mysql> select user from mysql.user;
+----------------+
| user |
+----------------+
| root |
+----------------+
6 rows in set (0.00 sec)
- database一覧取得
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
15 rows in set (0.00 sec)
- database選択
mysql> use 【database名】;
e.g.)
mysql> use mysql;
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
- table一覧取得
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
:
:
:
| time_zone_transition_type |
| user |
+---------------------------+
23 rows in set (0.00 sec)
- tableのcolumn一覧取得
mysql> desc 【table名】;
e.g.)
mysql> desc user;
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(16) | NO | PRI | | |
:
:
:
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) unsigned | NO | | 0 | |
+-----------------------+-----------------------------------+------+-----+---------+-------+
39 rows in set (0.00 sec)
更新日: 2013年07月12日 (金) 18時04分03秒