停止命令:net stop mysql
启动命令:net start mysql
C:\Windows\system32>net stop mysql
mysql 服务正在停止.
mysql 服务已成功停止。
C:\Windows\system32>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。
mysql -h ip -P 端口 -u 用户名 -p
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 10
Server version: 5.7.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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 --version 或者mysql -V( 用于在未登录情况下,查看本机mysql版本)
C:\Windows\system32>mysql -V
mysql Ver 14.14 Distrib 5.7.25, for Win64 (x86_64)
C:\Windows\system32>mysql --version
mysql Ver 14.14 Distrib 5.7.25, for Win64 (x86_64)
select version(); (登录情况下,查看数据库版本)
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.27-log |
+------------+
1 row in set (0.01 sec)
show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| boot_crm |
| employee |
| javacode2018 |
| mybatis |
| mysql |
| performance_schema |
| spring |
| ssmcrud |
| student |
+--------------------+
10 rows in set (0.01 sec)
use 数据库名;
mysql> use mybatis;
Database changed
show tables;
mysql> show tables;
+-------------------+
| Tables_in_mybatis |
+-------------------+
| acount |
| t_customer |
| t_student |
| t_user |
| tb_idcard |
| tb_orders |
| tb_ordersitem |
| tb_person |
| tb_product |
| tb_user |
+-------------------+
10 rows in set (0.00 sec)
show tables from 数据库名;
mysql> show tables from student;
+-------------------+
| Tables_in_student |
+-------------------+
| que |
| stu |
| tea |
+-------------------+
3 rows in set (0.00 sec)
show create table 表名;
mysql> show create table acount;
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| acount | CREATE TABLE `acount` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user_name` varchar(10) NOT NULL,
`balance` double(10,0) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
desc 表名;
mysql> desc acount;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| user_name | varchar(10) | NO | | NULL | |
| balance | double(10,0) | NO | | NULL | |
+-----------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
select database();
mysql> select database();
+------------+
| database() |
+------------+
| mybatis |
+------------+
1 row in set (0.00 sec)
SHOW ENGINES;
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)
SHOW VARIABLES;
mysql> SHOW VARIABLES;
+----------------------------------------------------------+--------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------+
| Variable_name | Value
|
+----------------------------------------------------------+--------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------+
| auto_increment_increment | 1
|
| auto_increment_offset | 1
|
| autocommit | ON
|
| automatic_sp_privileges | ON
|
| avoid_temporal_upgrade | OFF
|
| back_log | 90
|
| basedir |
D:\installsoft\MySQL\mysql-5.7.25-winx64\
......
.....
....
+----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
513 rows in set, 1 warning (0.00 sec)
SHOW VARIABLES like ‘变量名’;
mysql> SHOW VARIABLES like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set, 1 warning (0.00 sec)
mysql> SHOW VARIABLES like '%wait_timeou%t';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| innodb_lock_wait_timeout | 50 |
| lock_wait_timeout | 31536000 |
| wait_timeout | 28800 |
+--------------------------+----------+
3 rows in set, 1 warning (0.00 sec)
SHOW INDEXS FROM ‘表名’;
mysql> show index from tb_idcard;
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| tb_idcard | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | | |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.01 sec)
mysql> show index from tb_ordersitem;
+---------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| tb_ordersitem | 0 | PRIMARY | 1 | id | A | 3 | NULL | NULL | | BTREE | | |
| tb_ordersitem | 1 | orders_id | 1 | orders_id | A | 2 | NULL | NULL | | BTREE | | |
| tb_ordersitem | 1 | product_id | 1 | product_id | A | 2 | NULL | NULL | | BTREE | | |
+---------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)