首页 / MYSQL / MySQL 实用技巧
MySQL 实用技巧
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL 实用技巧,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3262字,纯文字阅读大概需要5分钟。
内容图文
![MySQL 实用技巧](/upload/InfoBanner/zyjiaocheng/469/3effac24361148ae9e882a6b3bc8f5fe.jpg)
Option | Description |
---|---|
\C |
The current connection identifier (MySQL 5.7.6 and up) |
\c |
A counter that increments for each statement you issue |
\D |
The full current date |
\d |
The default database |
\h |
The server host |
\l |
The current delimiter |
\m |
Minutes of the current time |
\n |
A newline character |
\O |
The current month in three-letter format (Jan, Feb, …) |
\o |
The current month in numeric format |
\P |
am/pm |
\p |
The current TCP/IP port or socket file |
\R |
The current time, in 24-hour military time (0–23) |
\r |
The current time, standard 12-hour time (1–12) |
\S |
Semicolon |
\s |
Seconds of the current time |
\t |
A tab character |
\U |
Your full |
\u |
Your user name |
\v |
The server version |
\w |
The current day of the week in three-letter format (Mon, Tue, …) |
\Y |
The current year, four digits |
\y |
The current year, two digits |
\_ |
A space |
\ |
A space (a space follows the backslash) |
\‘ |
Single quote |
\" |
Double quote |
\\ |
A literal “\ ” backslash character |
\ |
|
以下为配置示例:
1、在my.cnf配置文件[client]部分中增加以下配置
prompt="[\\r:\\m:\\s](\\U)[\\d] > " -- 在配置文件中配置都需要用\对配置的参数进行转义
[root@manager ~]# mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 5.7.10-log MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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. [03:11:57](root@localhost)[(none)] > -- 显示时间 + 登录用户 + 当前使用的数据库(未使用则为none)
[03:15:40](root@localhost)[test] >
2、在mysql客户端内直接配置
mysql>prompt [\r:\m:\s](\U)[\d] > PROMPT set to ‘[\r:\m:\s](\U)[\d] >‘
[03:22:31](root@localhost)[(none)] > -- 显示时间 + 登录用户 + 当前使用的数据库
[03:22:31](root@localhost)[(none)] >prompt (\U)[\d] >
PROMPT set to ‘(\U)[\d] >‘
(root@localhost)[(none)] > -- 只显示 登录用户 + 当前使用的数据库
二、tee/notee
功能:tee实现将命令行中的输入输出结果保存到文本文件中,使用该命令能方便的将命令进行日志记录。 用法:tee /tmp/command.log
以下为使用示例:
[03:43:49](root@localhost)[(none)] > tee /tmp/command.log -- 设置将输出的结果保存到文件中 Logging to file ‘/tmp/command.log‘ [03:44:02](root@localhost)[(none)] > show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | paralleldb | | performance_schema | | web | +--------------------+ 10 rows in set (0.00 sec) [03:44:18](root@localhost)[(none)] > system cat /tmp/command.log -- 通过system 命令查看系统文件内容与数据库中内容一致 [03:44:02](root@localhost)[(none)] > show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | paralleldb | | performance_schema | | web | +--------------------+ 10 rows in set (0.00 sec)
[03:46:55](root@localhost)[(none)] > notee -- 使用notee可结束文件的输出
Outfile disabled.
MySQL 实用技巧
标签:
本文系统来源:http://www.cnblogs.com/zhenxing/p/5697223.html
内容总结
以上是互联网集市为您收集整理的MySQL 实用技巧全部内容,希望文章能够帮你解决MySQL 实用技巧所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。