MySQL 服务常用操作命令
1、MySQL 服务设置
在使用
mysql.server
命令之前需要将路径/usr/local/mysql/support-files
添加到系统环境变量中。export PATH=$PATH:/usr/local/mysql/support-files
在使用
mysql
命令之前需要将路径/usr/local/mysql/bin
添加到系统环境变量中。export PATH=$PATH:/usr/local/mysql/bin
具体设置请参照《添加系统环境变量》章节。
2、MySQL 服务常用操作
2.1 MySQL 服务控制命令
MySQL 服务控制命令
# 启动 MySQL 服务
$ sudo mysql.server start Starting MySQL
.. SUCCESS!# 停止 MySQL 服务
$ sudo mysql.server stop Shutting down MySQL
.. SUCCESS!
# 重启 MySQL 服务
$ sudo mysql.server restart Shutting down MySQL
.. SUCCESS!
Starting MySQL
.. SUCCESS!
# 重新加载
$ sudo mysql.server reload SUCCESS! Reloading service MySQL
# 强制重新加载
$ sudo mysql.server force-reload SUCCESS! Reloading service MySQL
# 查看 MySQL 服务状态
$ mysql.server status ERROR! Multiple MySQL running but PID file could not be found (61998 62083 )
2.2 MySQL 服务连接命令
MySQL 服务连接命令
# 登录 MySQL 服务
# mysql -u 用户名 -p 密码
$ mysql -u root -p Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 930
Server version: 8.0.11 MySQL Community Server - GPL Copyright (c) 2000, 2018, 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>
# 登出 MySQL 服务
> exit Bye
3、MySQL 服务帮助操作
3.1 按照层次看帮助
如果不知道帮助能够提供什么,那么就可以直接用 “? contents” 命令来显示所有可供查询的分类,对于分类可以使用 “? 分类名称” 的方式针对用户感兴趣的内容做进一步的查看,通过这种 “? 类型别名” 的方式,就可以一层层的往下查找用户所关心的主题内容。
> ? 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
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility
3.2 快速查阅帮助
在实际应用中,如果需要快速查阅某项语法时,可以使用 “? 关键字” 方式进行快速查询。
> ? insert
Name: 'INSERT'
Description:
Syntax:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
{VALUES | VALUE} (value_list) [, (value_list)] ...
[ON DUPLICATE KEY UPDATE assignment_list] INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
SET assignment_list
[ON DUPLICATE KEY UPDATE assignment_list] INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
SELECT ...
[ON DUPLICATE KEY UPDATE assignment_list] value:
{expr | DEFAULT} value_list:
value [, value] ... assignment:
col_name = value assignment_list:
assignment [, assignment] ... INSERT inserts new rows into an existing table. The INSERT ... VALUES
and INSERT ... SET forms of the statement insert rows based on
explicitly specified values. The INSERT ... SELECT form inserts rows
selected from another table or tables. INSERT with an ON DUPLICATE KEY
UPDATE clause enables existing rows to be updated if a row to be
inserted would cause a duplicate value in a UNIQUE index or PRIMARY
KEY. For additional information about INSERT ... SELECT and INSERT ... ON
DUPLICATE KEY UPDATE, see [HELP INSERT SELECT], and
http://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html. In MySQL 8.0, the DELAYED keyword is accepted but ignored by the
server. For the reasons for this, see [HELP INSERT DELAYED], Inserting into a table requires the INSERT privilege for the table. If
the ON DUPLICATE KEY UPDATE clause is used and a duplicate key causes
an UPDATE to be performed instead, the statement requires the UPDATE
privilege for the columns to be updated. For columns that are read but
not modified you need only the SELECT privilege (such as for a column
referenced only on the right hand side of an col_name=expr assignment
in an ON DUPLICATE KEY UPDATE clause). When inserting into a partitioned table, you can control which
partitions and subpartitions accept new rows. The PARTITION option
takes a list of the comma-separated names of one or more partitions or
subpartitions (or both) of the table. If any of the rows to be inserted
by a given INSERT statement do not match one of the partitions listed,
the INSERT statement fails with the error Found a row not matching the
given partition set. For more information and examples, see
http://dev.mysql.com/doc/refman/8.0/en/partitioning-selection.html. URL: http://dev.mysql.com/doc/refman/8.0/en/insert.html
3.3 常用的网络资源
MySQL 官网 可以下载到各个版本的 MySQL 以及相关客户端开发工具等。
MySQL 在线手册 提供了目前最权威的 MySQL 数据库及工具的在线手册。
MySQL bug 列表 可以查看到 MySQL 已经发布的 bug 列表,或者向 MySQL 提交 bug 报告。
MySQL 的最新消息 通常会发布各种关于 MySQL 的最新消息。
MySQL 服务常用操作命令的更多相关文章
- Linux系统MySQL的常用操作命令
安装好MySQL服务后添加环境变量: #vi /etc/profile export MYSQL_HOME=/usr/local/mysql export PATH=$PATH:$MYSQL_HOME ...
- MySQL的常用操作命令详解
系统管理">系统管理 mysql服务">启动MySQL服务 通过windows服务管理器启动MySQL服务 ? 1 开始-->运行-->输入services ...
- MYSQL数据库常用操作命令
1.连接MYSQL: mysql -h 主机地址 -u 用户名 -p 2.修改密码: 安装后第一次登录使用: mysqladmin (因为没有初始密码) 修改原密码: mysqladmin -u ro ...
- mysql服务常用命令
一.查出当前mysql正在执行的sql命令mysql> show full processlist; 然后找出要终止的语句的idmysql> kill id号 未登录的情况下>mys ...
- 【Linux命令】mysql数据库常用操作命令
#数据库操作: #建立数据库 create database data_name #删除数据库 drop database data_name #查看: show databases; #表操作: # ...
- mysql 中启动服务的命令 、登录命令、退出命令 mysql 的常用命令
1.cmd 以管理员执行 下面命令 启动服务 :net start mysql57 关闭 服务:net stop mysql57 查看mysql 的版本信息 : mysql -V 指定主机地址登录: ...
- mysql 常用操作命令
mysql官网指南:http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html 1.导出整个数据库mysqldump -u 用户名 -p --defa ...
- ubuntu下mysql的常用命令,MySQL数据库的基本操作命令
一.mysql服务操作 0.查看数据库版本 sql-> status; 1.net start mysql //启动mysql服务 2.net stop mysql //停止mysql服务 3 ...
- 两种常用的启动和关闭MySQL服务
本博文的主要内容有 .通过图形界面来启动和关闭MySQL服务 .通过DOS窗口来启动和关闭MySQL服务 1.通过图形界面来启动和关闭MySQL服务 2.通过DOS窗口来启动和关闭MySQL服务 感谢 ...
随机推荐
- C语言中的模运算-hdu6124(打表,找规律)
题目链接:https://vjudge.net/problem/HDU-6124 题目描述: 题目大意就是给你一个数,判断这个数 % 其它数后共有几种结果. 这题对我来说最大的难点是我不太知道每个数 ...
- HDU 3416 Marriage Match IV 【最短路】(记录路径)+【最大流】
<题目链接> 题目大意: 给你一张图,问你其中没有边重合的最短路径有多少条. 解题分析: 建图的时候记得存一下链式后向边,方便寻找最短路径,然后用Dijkstra或者SPFA跑一遍最短路, ...
- 基于jest和puppeteer的前端自动化测试实战
前端测试现状 经常听到后端同学说“单元测试”,前端写过测试用例的有多少?答案是:并不多,为什么呢?两个主要原因 1.前端属于GUI软件,浏览器众多,兼容问题让人头大,用户量有一定规模的浏览器包括: I ...
- Unity容器在asp.net mvc中的IOC应用及AOP应用
<asp.net-mvc框架揭秘>一书中,有个示例,是使用unity容器来注入自定义的控制器工厂.代码示例可以自己去下载源码,在这里我就不说了.IOC容器的本质是解耦的实例化接口类,而如何 ...
- maven 构建spring boot + mysql 的基础项目
一.maven 依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId> ...
- position 属性的值的比较
可取的四个值:static/relative/absolute/fixed static:默认值,top/right/bottom/left 无作用,z-index无效 relative:相对于原来的 ...
- 牛客国庆集训派对Day1.B.Attack on Titan(思路 最短路Dijkstra)
题目链接 \(Description\) 给定\(n,m,C\)及大小为\((n+1)(m+1)\)的矩阵\(c[i][j]\).平面上有\((n+1)(m+1)\)个点,从\((0,0)\)编号到\ ...
- BZOJ.2726.[SDOI2012]任务安排(DP 斜率优化)
题目链接 数据范围在这:https://lydsy.com/JudgeOnline/wttl/thread.php?tid=613, 另外是\(n\leq3\times10^5\). 用\(t_i\) ...
- 51nod 算法马拉松30
题目链接 附一个代码地址 A,这个容斥一下就好了 C,rxd大爷给讲的,首先如果分三种情况(成环,正在比配环,未访问)讨论复杂度是\(3^n * n ^ 2\)的,但是对于每一个环,都可以直接枚举环的 ...
- LeetCode之旅
14. 最长公共前缀 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower",&quo ...