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. DT:DT实现根据乳腺肿瘤特征向量高精度预测肿瘤的是恶性还是良性—Jason niu

    %DT:DT实现根据乳腺肿瘤特征向量高精度预测肿瘤的是恶性还是良性 load data.mat a = randperm(569); Train = data(a(1:500),:); Test = ...

  2. TF之RNN:实现利用scope.reuse_variables()告诉TF想重复利用RNN的参数的案例—Jason niu

    import tensorflow as tf # 22 scope (name_scope/variable_scope) from __future__ import print_function ...

  3. a标签下划线

    页面中有一处box中的a标签都被加上了下划线,查找元素却没有找到css中的underline. 原因是 <a>标签默认是有下划线的,而一般看到的<a>标签链接中的下划线都被覆盖 ...

  4. Java 并发工具包 | J.U.C

    不知道大家还有没有印象,上次我们已经说过了,我们为了实现集合相关类的线程安全,JDK 提供了一套同步容器,也就是 Vector,Hashtable,还有一个 Collections 工具类中的几个方法 ...

  5. 2018ddctf wp

    杂项 第一题:颜文字 看过以后开始没思路:后来有师傅说是十六进制 我就上网百度了一下http://tieba.baidu.com/p/3717777553 但是不可能是完全十六进制啊,毕竟出题人很羞涩 ...

  6. [Python]mysql-python 安装错误 fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

    需要安装mysql connector 前往 https://dev.mysql.com/downloads/connector/python/ 下载 选择Platform independence, ...

  7. SFTPUtils工具类及使用

    配置maven <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</arti ...

  8. 【DWM1000】 code 解密5一ACHOR 第一次回家Main 函数

    instance_run(); if((instance_data[0].monitor == 1) && ((portGetTickCnt() - instance_data[0]. ...

  9. lnmp更改网站文件和MySQL数据库的存放目录

    购买阿里云服务器,一般建议买一个数据盘,也就是系统盘和数据盘分开,将网站文件和Mysql数据库等都保存在数据盘,即使系统盘或者环境出问题,重置系统盘和重新配置环境,都不会影响数据盘的东西. 配置好LN ...

  10. JavaScript之中Array用法的一些技巧总结

    1.创建一个全部为0,长度为100的数组(ES6) Array(10).fill(0) 2.创建一个长度为100的数组,其中保存0 ~ 99 let array = Array(100).fill(0 ...