mysql客户端登陆配置
admin
2023-05-05 02:00:53
0

my.cnf配置文件参数设置:

[root@cacti ~]# head -7 /etc/my.cnf

[mysql]
prompt="(\\u@\\h:\R:\m:\\s)[\\d]> "
pager="less -i -n -S"
tee="/tmp/query.log"
no-auto-rehash

[mysqld]

配置文件参数介绍:
这样就能很方便的知道当前位于哪个mysql db上,正在以哪个用户登录,对哪个数据库进行操作,防止误操作;并且还能显示当前时间。
tee="/tmp/query.log" 是把每次查询的SQL及其结果都记录到 /tmp/query.log 里,便于追踪。
pager="less -i -n -S" 则是把每次输出都用less来控制显示,便于输出结果格式更加容易阅读,尤其是行记录长度超过一屏宽度时。

重启MySQL服务
[root@cacti ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL... SUCCESS!

登录mysql后将有以下提示

[root@cacti ~]# mysql -uroot -p'xiaowytest' -S /tmp/mysql3307.sock 
**Logging to file '/tmp/query.log'**
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.20-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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.

(root@localhost:17:53:43)[(none)]>
(root@localhost:17:53:43)[(none)]> use ranzhidb;
Database changed
(root@localhost:17:56:15)[ranzhidb]> select id,account from droa_attend where id=10 and account='xiawu';
Empty set (0.00 sec)

(root@localhost:17:57:08)[ranzhidb]> select id,account from droa_attend where id=10 and account='xiaowu';
+----+---------+
| id | account |
+----+---------+
| 10 | xiaowu  |
+----+---------+
1 row in set (0.00 sec)

[root@cacti ~]# tailf /tmp/query.log

Server version: 5.6.20-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, 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.
(root@localhost:17:53:43)[(none)]> use ranzhidb;
Database changed
(root@localhost:17:56:15)[ranzhidb]> select id,account from droa_attend where id=10 and account='xiawu';
Empty set (0.00 sec)

(root@localhost:17:57:08)[ranzhidb]> select id,account from droa_attend where id=10 and account='xiaowu';
+----+---------+
| id | account |
+----+---------+
| 10 | xiaowu  |
+----+---------+
1 row in set (0.00 sec)

参考博文地址:http://www.imysql.cn/2008_07_09_show_mysql_client_settings

相关内容

热门资讯

菲律宾总统称未下达逮捕德拉罗萨... 新华社马尼拉5月13日电(记者赵晨捷 李萌)据菲律宾媒体报道,菲总统马科斯13日称未下达逮捕参议员德...
时隔九年再度来京,特朗普有何诉... ◆5月12日,特朗普登上“空军一号”前对着镜头挥手告别。(图源:美联社)文/何平编辑/漆菲5月13日...
硬科技管控,中美关系的新压舱石 特朗普此次访华,英伟达CEO黄仁勋随行的消息提振美股市场,凸显芯片与人工智能已成为中美关系的核心议题...
报告:今年一季度AI原生APP... 中国青年网北京5月12日电(记者 高蕾)近日,第三方智能数据服务商QuestMobile发布了《中国...
七大新品发布!国轩高科第15届... 央广网合肥5月13日消息(记者徐鹏)5月16日至17日,电池龙头企业国轩高科将在合肥举办第15届全球...
百度伐谋2.0发布,李彦宏:能... 5月13日举办的Create2026百度AI开发者大会开幕式上,自我演化决策智能体百度伐谋升级至2....
泰顶级豪门曝性侵丑闻!哥哥侵犯... 泰国最有影响力的巨头之一Singha集团(胜狮集团),这两天爆出性侵丑闻。集团第四代成员,环保活动家...
什么信号?多地要求干部带头缴纳... 多地要求干部带头缴纳物业费。最近一段时间,物业费成了社会关注的焦点。原因竟然是多地密集出台文件,号召...
“这不是威胁而是绝佳机遇”,默... 【文/观察者网 张菁娟】“当下挑战之所以如此巨大,是因为我们长期以来为自己制造了太多问题,而这些问题...
老杜盟友半路杀出,“闪电夺权”... 最近两天,马尼拉的政治温度直接爆表。5月11日上午,菲律宾众议院以255票赞成、26票反对、9票弃权...