菜鸟笔记
提升您的技术认知

MySQL数据库 基本操作

1. 基本操作

对mysql数据库的基本操作,启动,关闭,登录,退出,帮助等等……

脑图

启动mysql服务

net start mysql

C:\Windows\System32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

关闭mysql服务

net stop mysql

C:\Windows\System32>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。

登录mysql服务

注意,地址就是ip,本地可以写localhost和127.0.0.1,端口就是mysql启动服务占用的端口号 默认是3306

mysql -h 地址 -P 端口 -u root -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 3
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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登录

ctrl + z 回车
exit
quit

显示哪些线程正在运行

show processlist;

mysql> show processlist;
+----+------+-----------+------+---------+------+----------+------------------+
| Id | User | Host      | db   | Command | Time | State    | Info             |
+----+------+-----------+------+---------+------+----------+------------------+
|  4 | root | localhost | NULL | Query   |    0 | starting | show processlist |
+----+------+-----------+------+---------+------+----------+------------------+
1 row in set (0.03 sec)

查看帮助

help 关键字;