十九、MySQL常用命令总结
數據結構核心原理與算法應用
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: ****
mysql> exit
ByeC:\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
ByeC:\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 changedmysql> 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));
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: 0mysql> 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
ByeC:\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: ****
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 changedmysql> select * from stuinfo;
+------+------+ | id | name | +------+------+ | 2 | rose | +------+------+ 1 row in set (0.00 sec)mysql> select *
-> from stuinfo;
mysql> SELECT
-> *
-> FROM
-> stuinfo;
mysql> select * from stuinfo;
+------+------+ | id | name | +------+------+ | 2 | rose | +------+------+ 1 row in set (0.00 sec)總結
以上是生活随笔為你收集整理的十九、MySQL常用命令总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vuex4学习笔记
- 下一篇: linux cmake编译源码,linu