一、MySQL启动方式
1、Windows:
方法一:
以管理员身份运行cmd打开dos窗口,输入net start mysql80
。(mysql80为实际服务名称)
C:\Users\Administrator>net start mysql80
MySQL80 服务正在启动 .
MySQL80 服务已经启动成功。
C:\Users\Administrator>net stop mysql80
MySQL80 服务正在停止.
MySQL80 服务已成功停止。
方法二:用cmd输入services.msc
打开windows服务,找到MySQL服务右键点击启动。
2、Linux:
service mysql start # 启动
service mysql stop # 停止
service mysql restart # 重启
service mysql status # 查看状态
systemctl start mysql
systemctl stop mysql
systemctl restart mysql
systemctl status mysql
二、连接MySQL
语法:
$> mysql -h host -u user -p
Enter password: ********
如:
[nosee@instance-4 /]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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
[nosee@instance-4 /]$
三、SQL语句
SQL语句的分类:DDL、DML、DQL、DCL
- DDL(Data Definition Language)数据定义语言
用来定义数据库对象:数据库
、表
、列
等。关键词:create
、drop
、alter
等 - DML(Data Manipulation Language)数据操作语言
用来对数据库中表的数据
进行增删改。关键词:insert
、delete
、update
等 - DQL(Data Query Language)数据查询语言
用来查询数据库中表的数据
。关键词:select
、where
等 - DCL(Data Control Language)数据控制语言
用来定义数据库的访问权限``和安全级别
,及创建用户
。关键词:grant
、revoke
等
四、查看帮助
mysql> help contents;
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
Account Management
Administration
Components
Compound Statements
Contents
Data Definition
Data Manipulation
Data Types
Functions
Geographic Features
Help Metadata
Language Structure
Loadable Functions
Plugins
Prepared Statements
Replication Statements
Storage Engines
Table Maintenance
Transactions
Utility
mysql>
网友评论