zoukankan      html  css  js  c++  java
  • mysql自定义命令行提示prompt

    官方资料入口

      在《MySQL 5.7 Reference Manual》的如下章节可以看到自定义命令提示的描述:

      https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html

      MySQL 5.7 Reference Manual -->Chapter 4 MySQL Programs -->4.5 Client Programs -->4.5.1 mysql — The MySQL Command-Line Client -->4.5.1.2 mysql Client Commands

    PROMPT自定义实践

      官方给出有4种方式可以实现命令行自定义。

      1、调整系统环境变量,使用MYSQL_PS1  

    [mysql@zsdb script]$ export MYSQL_PS1="(u@h) [d]> "       <=======MYSQL_PS1
    [mysql@zsdb script]$ ./m3306.sh 
    。。。。。。。
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    (root@localhost) [(none)]> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    (root@localhost) [mysql]> 

      2、在mysql命令使用--prompt参数

    [mysql@zsdb script]$ /u01/mysql5.7/svr/bin/mysql --prompt="(u@h) [d]> " -uroot --socket=/u01/mysql5.7/run/my3306/mysql.sock -p123456
    。。。。。。。
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    (root@localhost) [(none)]> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    (root@localhost) [mysql]>

      3、编辑*.cnf文件,添加prompt选项

      [mysql]

      prompt=(\u@\h) [\d]>\_  

    [mysql@zsdb script]$ ./m3306.sh 
    。。。。。
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    (root@localhost) [(none)]> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    (root@localhost) [mysql]> 

      4、sql交互窗口使用prompt  

    [mysql@zsdb script]$ ./m3307.sh 
    。。。。。。
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> prompt (u@h) [d]>\_        <======= 参数调整
    PROMPT set to '(u@h) [d]>\_'
    (root@localhost) [(none)]> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    (root@localhost) [mysql]> 

    PROMPT选项一览

  • 相关阅读:
    160328、rabbitMQ集群部署示例
    160325、虚拟机三种网路设置
    160324、特殊时间下拉框
    export export-default import 使用场景
    vue项目工具文件utils.js javascript常用工具类,javascript常用工具类,util.js
    如何在vuejs中抽出公共代码
    vue 各种 import 引入
    es6环境中,export与import使用方法
    基于rem的移动端响应式适配方案(详解) 移动端H5页面的设计稿尺寸大小规范
    JS获取子节点、父节点和兄弟节点的方法实例总结
  • 原文地址:https://www.cnblogs.com/bicewow/p/12298041.html
Copyright © 2011-2022 走看看