常见命令

Microsoft Windows [版本 6.1.7600]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Windows\system32>net stop mysql0815
MySQL0815 服务正在停止.
MySQL0815 服务已成功停止。

C:\Windows\system32>net start mysql0815
MySQL0815 服务正在启动 .
MySQL0815 服务已经启动成功。

C:\Windows\system32>mysql -h localhost -P 3306 -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> exit
Bye

C:\Windows\system32>mysql -h localhost -P 3306 -u root -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> exit
Bye

C:\Windows\system32>mysql -u root -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> show tables from mysql;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
24 rows in set (0.00 sec)

mysql> select database();
+------------+
| database() |
+------------+
| test |
+------------+
1 row in set (0.00 sec)

mysql> create table stuinfo(
-> id int,
-> name varchar(20));
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| stuinfo |
+----------------+
1 row in set (0.00 sec)

mysql> desc stuinfo;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> select * from stuinfo;
Empty set (0.00 sec)

mysql> insert into stuinfo (id,name) values(1,'john');
Query OK, 1 row affected (0.00 sec)

mysql> insert into stuinfo (id,name) values(2,'rose');
Query OK, 1 row affected (0.00 sec)

mysql> select * from stuinfo;
+------+------+
| id | name |
+------+------+
| 1 | john |
| 2 | rose |
+------+------+
2 rows in set (0.00 sec)

mysql> update stuinfo set name='lilei' where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from stuinfo;
+------+-------+
| id | name |
+------+-------+
| 1 | lilei |
| 2 | rose |
+------+-------+
2 rows in set (0.00 sec)

mysql> delete from stuinfo where id=1;
Query OK, 1 row affected (0.00 sec)

mysql> select * from stuinfo;
+------+------+
| id | name |
+------+------+
| 2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.5.15 |
+-----------+
1 row in set (0.00 sec)

mysql> exit
Bye

C:\Windows\system32>mysql --version
mysql Ver 14.14 Distrib 5.5.15, for Win32 (x86)

C:\Windows\system32>mysql -V
mysql Ver 14.14 Distrib 5.5.15, for Win32 (x86)

C:\Windows\system32>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> SHOW DATABASES\g
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> select * from stuinfo;
+------+------+
| id | name |
+------+------+
| 2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> select *
-> from stuinfo;
+------+------+
| id | name |
+------+------+
| 2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> SELECT
-> *
-> FROM
-> stuinfo;
+------+------+
| id | name |
+------+------+
| 2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> select * from stuinfo;
+------+------+
| id | name |
+------+------+
| 2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> #select * from stuinfo;
mysql>

数据库入门与基础操作 文章被收录于专栏

数据库是“按照数据结构来组织、存储和管理数据的仓库”。是一个长期存储在计算机内的、有组织的、可共享的、统一管理的大量数据的集合。 数据库是以一定方式储存在一起、能与多个用户共享、具有尽可能小的冗余度、与应用程序彼此独立的数据集合,可视为电子化的文件柜——存储电子文件的处所,用户可以对文件中的数据进行新增、查询、更新、删除等操作。

全部评论

相关推荐

一名愚蠢的人类:多少games小鬼留下了羡慕的泪水
投递荣耀等公司10个岗位
点赞 评论 收藏
分享
可可可可可_:nb啊,看样子是专科玩了几年随便专升本了个民办,又玩了两年。你这能找到我吃
点赞 评论 收藏
分享
评论
点赞
1
分享
牛客网
牛客企业服务