1、MySQL 服务设置

  • 在使用 mysql.server 命令之前需要将路径 /usr/local/mysql/support-files 添加到系统环境变量中。

    1. export PATH=$PATH:/usr/local/mysql/support-files
  • 在使用 mysql 命令之前需要将路径 /usr/local/mysql/bin 添加到系统环境变量中。

    1. export PATH=$PATH:/usr/local/mysql/bin
  • 具体设置请参照《添加系统环境变量》章节。

2、MySQL 服务常用操作

2.1 MySQL 服务控制命令

  • MySQL 服务控制命令

    1. # 启动 MySQL 服务
    2. $ sudo mysql.server start
    3. Starting MySQL
    4. .. SUCCESS!
    1. # 停止 MySQL 服务
    2. $ sudo mysql.server stop
    3. Shutting down MySQL
    4. .. SUCCESS!
    1. # 重启 MySQL 服务
    2. $ sudo mysql.server restart
    3. Shutting down MySQL
    4. .. SUCCESS!
    5. Starting MySQL
    6. .. SUCCESS!
    1. # 重新加载
    2. $ sudo mysql.server reload
    3. SUCCESS! Reloading service MySQL
    1. # 强制重新加载
    2. $ sudo mysql.server force-reload
    3. SUCCESS! Reloading service MySQL
    1. # 查看 MySQL 服务状态
    2. $ mysql.server status
    3. ERROR! Multiple MySQL running but PID file could not be found (61998 62083 )

2.2 MySQL 服务连接命令

  • MySQL 服务连接命令

    1. # 登录 MySQL 服务
    2. # mysql -u 用户名 -p 密码
    3. $ mysql -u root -p
    4. Enter password:
    5. Welcome to the MySQL monitor. Commands end with ; or \g.
    6. Your MySQL connection id is 930
    7. Server version: 8.0.11 MySQL Community Server - GPL
    8. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    9. Oracle is a registered trademark of Oracle Corporation and/or its
    10. affiliates. Other names may be trademarks of their respective
    11. owners.
    12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    13. mysql>
    1. # 登出 MySQL 服务
    2. > exit
    3. Bye

3、MySQL 服务帮助操作

3.1 按照层次看帮助

  • 如果不知道帮助能够提供什么,那么就可以直接用 “? contents” 命令来显示所有可供查询的分类,对于分类可以使用 “? 分类名称” 的方式针对用户感兴趣的内容做进一步的查看,通过这种 “? 类型别名” 的方式,就可以一层层的往下查找用户所关心的主题内容。

    1. > ? contents
    2. You asked for help about help category: "Contents"
    3. For more information, type 'help <item>', where <item> is one of the following
    4. categories:
    5. Account Management
    6. Administration
    7. Components
    8. Compound Statements
    9. Data Definition
    10. Data Manipulation
    11. Data Types
    12. Functions
    13. Functions and Modifiers for Use with GROUP BY
    14. Geographic Features
    15. Help Metadata
    16. Language Structure
    17. Plugins
    18. Storage Engines
    19. Table Maintenance
    20. Transactions
    21. User-Defined Functions
    22. Utility

3.2 快速查阅帮助

  • 在实际应用中,如果需要快速查阅某项语法时,可以使用 “? 关键字” 方式进行快速查询。

    1. > ? insert
    2. Name: 'INSERT'
    3. Description:
    4. Syntax:
    5. INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    6. [INTO] tbl_name
    7. [PARTITION (partition_name [, partition_name] ...)]
    8. [(col_name [, col_name] ...)]
    9. {VALUES | VALUE} (value_list) [, (value_list)] ...
    10. [ON DUPLICATE KEY UPDATE assignment_list]
    11. INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    12. [INTO] tbl_name
    13. [PARTITION (partition_name [, partition_name] ...)]
    14. SET assignment_list
    15. [ON DUPLICATE KEY UPDATE assignment_list]
    16. INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
    17. [INTO] tbl_name
    18. [PARTITION (partition_name [, partition_name] ...)]
    19. [(col_name [, col_name] ...)]
    20. SELECT ...
    21. [ON DUPLICATE KEY UPDATE assignment_list]
    22. value:
    23. {expr | DEFAULT}
    24. value_list:
    25. value [, value] ...
    26. assignment:
    27. col_name = value
    28. assignment_list:
    29. assignment [, assignment] ...
    30. INSERT inserts new rows into an existing table. The INSERT ... VALUES
    31. and INSERT ... SET forms of the statement insert rows based on
    32. explicitly specified values. The INSERT ... SELECT form inserts rows
    33. selected from another table or tables. INSERT with an ON DUPLICATE KEY
    34. UPDATE clause enables existing rows to be updated if a row to be
    35. inserted would cause a duplicate value in a UNIQUE index or PRIMARY
    36. KEY.
    37. For additional information about INSERT ... SELECT and INSERT ... ON
    38. DUPLICATE KEY UPDATE, see [HELP INSERT SELECT], and
    39. http://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html.
    40. In MySQL 8.0, the DELAYED keyword is accepted but ignored by the
    41. server. For the reasons for this, see [HELP INSERT DELAYED],
    42. Inserting into a table requires the INSERT privilege for the table. If
    43. the ON DUPLICATE KEY UPDATE clause is used and a duplicate key causes
    44. an UPDATE to be performed instead, the statement requires the UPDATE
    45. privilege for the columns to be updated. For columns that are read but
    46. not modified you need only the SELECT privilege (such as for a column
    47. referenced only on the right hand side of an col_name=expr assignment
    48. in an ON DUPLICATE KEY UPDATE clause).
    49. When inserting into a partitioned table, you can control which
    50. partitions and subpartitions accept new rows. The PARTITION option
    51. takes a list of the comma-separated names of one or more partitions or
    52. subpartitions (or both) of the table. If any of the rows to be inserted
    53. by a given INSERT statement do not match one of the partitions listed,
    54. the INSERT statement fails with the error Found a row not matching the
    55. given partition set. For more information and examples, see
    56. http://dev.mysql.com/doc/refman/8.0/en/partitioning-selection.html.
    57. 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. 关闭selinux服务

    vim /etc/selinux/config 将SELINUX=disabled 执行setenforce 0

  2. 在思科路由器上配置AAA认证

    1.实验拓扑 网络情况 PC-A PING PC-B PC-A PING PC-C PC-B PING PC-C 2.R1的配置 a.console线 R1(config)#username admi ...

  3. Splay的初步学习

    具体是啥,qwq 有时间再补吧,贴一下代码: #include<iostream> #include<cstdio> #include<cstring> #incl ...

  4. SpringMVC(二六) SpringMVC配置文件中使用mvc:view-controller标签

    在springmvc中使用mvc:view-controller标签直接将访问url和视图进行映射,而无需要通过控制器. 参考springmvc.xml内容: <?xml version=&qu ...

  5. python基础一 ------如何获取多个字典相同的键

    需求: 足球赛第一场进去统计  {"A":3,"B":2,"C":1}足球赛第二场进去统计  {"A":3," ...

  6. Linux搭建 SVN 服务器

    安装 Subversion Subversion 是一个版本控制系统,相对于的 RCS . CVS ,采用了分支管理系统,它的设计目标就是取代 CVS . yum install -y subvers ...

  7. 双向BFS—>NOIP2002 字串变换

    如果目标也已知的话,用双向BFS能很大提高速度 单向时,是 b^len的扩展. 双向的话,2*b^(len/2)  快了很多,特别是分支因子b较大时 至于实现上,网上有些做法是用两个队列,交替节点搜索 ...

  8. html页面布局之table布局:

    table布局: table来做整体页面的布局,布局技巧归纳如下: (1)按照设计图的尺寸设置表格的宽高以及单元格的宽高 (2)将表格的border.cellpadding.cellspacing全部 ...

  9. linux 时间同步的2种方法(转)

    linux 时间同步的2种方法 张映 发表于 2012-10-23 分类目录: 服务器相关 标签:linux, ntp, 同步, 时间服务器 由于硬件的原因,机器或多或少的根标准时间对不上,一个月的误 ...

  10. hdu3466 Proud Merchants(01背包)

    https://vjudge.net/problem/HDU-3466 一开始想到了是个排序后的背包,但是排序的策略一直没对. 两个物品1和2,当p1+q2>p2+q1 => q1-p1& ...