MySQL使用指南一

来源:互联网 发布:淘宝网华为mate7手机壳 编辑:程序博客网 时间:2024/06/05 14:21

   我将MySQL常用指令整理出来分享给大家。


1. 列出所有数据库
mysql> show databases;
 
2. 创建数据库
mysql> create databases MyStorage;
 
3. 打开数据库
mysql> use MyStorage;
 
4. 创建表
mysql> create table Storage
    -> (
    -> id int,
    -> name varchar(50),
    -> price float,
    -> type nvarchar(50),
    -> number int,
    -> makeTime date,
-> useDay int);

 
5. 显示所有的表
mysql> show tables;
 
6. 显示表详细信息
mysql> describe storage;
 
7. 将文本文件sotrage.txt中的记录导入到表中
mysql> load data local infile 'e:/storage.txt' into table storage
-> lines terminated by '/r/n';
 
8. 显示表中的记录
mysql> SELECT * FROM storage;
 
9. 向表中插入记录
mysql> insert into storage
-> values (8,'风衣',300,'服装',3650,'2011-3-1',0);
 
10. 删除表中的记录
mysql> delete from storage where id=8;
 
11. 修改表中的记录
mysql> update storage set price=1000 where id=7;
 
12. 显示mysql中所有账户
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mystorage          |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> use mysql;
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)

mysql> select * from user;
+-----------+------+-------------------------------------------+-------------+--
-----------+-------------+-------------+-------------+-----------+-------------+
---------------+--------------+-----------+------------+-----------------+------
------+------------+--------------+------------+-----------------------+--------
----------+--------------+-----------------+------------------+-----------------
-+----------------+---------------------+--------------------+------------------
+----------+------------+-------------+--------------+---------------+----------
---+-----------------+----------------------+
| Host      | User | Password                                  | Select_priv | I
nsert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv |
 Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index
_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_ta
bles_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv
 | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv
| ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updat
es | max_connections | max_user_connections |
+-----------+------+-------------------------------------------+-------------+--
-----------+-------------+-------------+-------------+-----------+-------------+
---------------+--------------+-----------+------------+-----------------+------
------+------------+--------------+------------+-----------------------+--------
----------+--------------+-----------------+------------------+-----------------
-+----------------+---------------------+--------------------+------------------
+----------+------------+-------------+--------------+---------------+----------
---+-----------------+----------------------+
| localhost | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | Y           | Y
           | Y           | Y           | Y           | Y         | Y           |
 Y             | Y            | Y         | Y          | Y               | Y
      | Y          | Y            | Y          | Y                     | Y
          | Y            | Y               | Y                | Y
 | Y              | Y                   | Y                  | Y
|          |            |             |              |             0 |
 0 |               0 |                    0 |
+-----------+------+-------------------------------------------+-------------+--
-----------+-------------+-------------+-------------+-----------+-------------+
---------------+--------------+-----------+------------+-----------------+------
------+------------+--------------+------------+-----------------------+--------
----------+--------------+-----------------+------------------+-----------------
-+----------------+---------------------+--------------------+------------------
+----------+------------+-------------+--------------+---------------+----------
---+-----------------+----------------------+
1 row in set (0.00 sec)

原创粉丝点击