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 服务常用操作命令的更多相关文章

  1. Linux系统MySQL的常用操作命令

    安装好MySQL服务后添加环境变量: #vi /etc/profile export MYSQL_HOME=/usr/local/mysql export PATH=$PATH:$MYSQL_HOME ...

  2. MySQL的常用操作命令详解

    系统管理">系统管理 mysql服务">启动MySQL服务 通过windows服务管理器启动MySQL服务 ? 1 开始-->运行-->输入services ...

  3. MYSQL数据库常用操作命令

    1.连接MYSQL: mysql -h 主机地址 -u 用户名 -p 2.修改密码: 安装后第一次登录使用: mysqladmin (因为没有初始密码) 修改原密码: mysqladmin -u ro ...

  4. mysql服务常用命令

    一.查出当前mysql正在执行的sql命令mysql> show full processlist; 然后找出要终止的语句的idmysql> kill id号 未登录的情况下>mys ...

  5. 【Linux命令】mysql数据库常用操作命令

    #数据库操作: #建立数据库 create database data_name #删除数据库 drop database data_name #查看: show databases; #表操作: # ...

  6. mysql 中启动服务的命令 、登录命令、退出命令 mysql 的常用命令

    1.cmd 以管理员执行 下面命令 启动服务 :net start mysql57 关闭 服务:net stop mysql57 查看mysql 的版本信息 : mysql -V 指定主机地址登录: ...

  7. mysql 常用操作命令

    mysql官网指南:http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html 1.导出整个数据库mysqldump -u 用户名 -p --defa ...

  8. ubuntu下mysql的常用命令,MySQL数据库的基本操作命令

    一.mysql服务操作 0.查看数据库版本 sql-> status; 1.net start mysql //启动mysql服务 2.net stop mysql //停止mysql服务  3 ...

  9. 两种常用的启动和关闭MySQL服务

    本博文的主要内容有 .通过图形界面来启动和关闭MySQL服务 .通过DOS窗口来启动和关闭MySQL服务 1.通过图形界面来启动和关闭MySQL服务 2.通过DOS窗口来启动和关闭MySQL服务 感谢 ...

随机推荐

  1. 生日蛋糕 POJ - 1190 (搜索+剪枝)

    7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体. 设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱.当 ...

  2. UVa 11987 Almost Union-Find (虚拟点)【并查集】

    <题目链接> 题目大意: 刚开始,1到n个集合中分别对应着1~n这些元素,然后对这些集合进行三种操作: 输入 1 a b 把a,b所在的集合合并 输入 2 a b 把b从b所在的旧集合移到 ...

  3. 【Spring Boot】构造、访问Restful Webservice与定时任务

    Spring Boot Guides Examples(1~3) 参考网址:https://spring.io/guides 创建一个RESTful Web Service 使用Eclipse 创建一 ...

  4. Jmeter实现Basic Auth方式登录

    背景 在实际测试日常中,产品有两种登录方式,一种是普通登录方式,另一种则是Basic Auth方式登录.两种登录对应着产品中不同的操作,对权限进行了一个划分. Postman登录 使用Postman登 ...

  5. oracle 重复只保留一条

    DELETE FROM xx WHERE ROWID NOT IN (SELECT MIN(ROWID) FROM xx  GROUP BY xx, xx);

  6. BZOJ-7-2655: calc-DP-拉格朗日插值

    https://www.lydsy.com/JudgeOnline/problem.php?id=2655 以上是对 dp 一小部分打的表.dp[ i ] [ j ]  含义为 前 i 个 数 中 选 ...

  7. 橡皮筋进度条ElasticProgressBar

    橡皮筋进度条ElasticProgressBar 橡皮筋进度条是一个极具动画效果的进度条.该进度条不仅具有皮筋效果,还带有进度数据显示,让用户可以很清晰的看到当前的进度,可用于下载.加载进度等场景.E ...

  8. Java笔记(一)编程基础与二进制

    编程基础与二进制 一.编程基础 函数调用的基本原理: 函数调用中的问题: 1)参数如何传递? 2)函数如何知道返回什么地方? 3)函数结果如何传递给调用方? 解决思路是使用内存来函数调用过程中需要的数 ...

  9. (Android数据传递)Service和Activity之间-- 借助BroadcastReceiver--的数据传递

    实现逻辑如下: 左侧为Activity中的执行逻辑,右侧为Service中的执行逻辑: /** * <功能描述> Service和Activity之间的数据交互:具体表现为: 1. 从Se ...

  10. php include 绝对路径 dirname(__FILE__)

     include(dirname(__FILE__)."/PHPMailer/function.php");