my.cnf配置文件參數(shù)設(shè)置:
成都創(chuàng)新互聯(lián)公司是一家專業(yè)提供黃岡企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、做網(wǎng)站、H5網(wǎng)站設(shè)計、小程序制作等業(yè)務(wù)。10年已為黃岡眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。
[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]
配置文件參數(shù)介紹:
這樣就能很方便的知道當(dāng)前位于哪個mysql db上,正在以哪個用戶登錄,對哪個數(shù)據(jù)庫進(jìn)行操作,防止誤操作;并且還能顯示當(dāng)前時間。
tee="/tmp/query.log" 是把每次查詢的SQL及其結(jié)果都記錄到 /tmp/query.log 里,便于追蹤。
pager="less -i -n -S" 則是把每次輸出都用less來控制顯示,便于輸出結(jié)果格式更加容易閱讀,尤其是行記錄長度超過一屏寬度時。
重啟MySQL服務(wù):
[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