配置文件路径:

/data/mysql/mysql3306/my.cnf

[client]
port = 3306

[mysql]
auto-rehash
prompt="\\u@\\h:\\p [\\d]>"
#pager="less -i -n -S"
#tee=/opt/mysql/query.log

[root@edu ~]# mysql -S /tmp/mysql3306.sock -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.7.22-log MySQL Community Server (GPL)

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

mysql>

分析启动过程:

[root@zstedu ~]# strace /usr/local/mysql/bin/mysql --print-defaults
execve("/usr/local/mysql/bin/mysql", ["/usr/local/mysql/bin/mysql", "--print-defaults"], [/* 22 vars */]) = 0
brk(NULL) = 0xa6f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd222000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22349, ...}) = 0
mmap(NULL, 22349, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2cbd21c000
close(3) = 0
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0m\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144792, ...}) = 0
mmap(NULL, 2208904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbcde6000
mprotect(0x7f2cbcdfd000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbcffc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f2cbcffc000
mmap(0x7f2cbcffe000, 13448, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2cbcffe000
close(3) = 0
open("/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\"\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=44448, ...}) = 0
mmap(NULL, 2128952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbcbde000
mprotect(0x7f2cbcbe5000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbcde4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f2cbcde4000
close(3) = 0
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19776, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd21b000
mmap(NULL, 2109744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbc9da000
mprotect(0x7f2cbc9dc000, 2097152, PROT_NONE) = 0
mmap(0x7f2cbcbdc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f2cbcbdc000
close(3) = 0
open("/lib64/libncurses.so.5", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0Pm\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=163696, ...}) = 0
mmap(NULL, 2254920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbc7b3000
mprotect(0x7f2cbc7d9000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbc9d8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7f2cbc9d8000
close(3) = 0
open("/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \262\5\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=991616, ...}) = 0
mmap(NULL, 3171168, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbc4ac000
mprotect(0x7f2cbc595000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbc794000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe8000) = 0x7f2cbc794000
mmap(0x7f2cbc79e000, 82784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2cbc79e000
close(3) = 0
open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0pS\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1139680, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd21a000
mmap(NULL, 3150136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbc1aa000
mprotect(0x7f2cbc2ab000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbc4aa000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x100000) = 0x7f2cbc4aa000
close(3) = 0
open("/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=88776, ...}) = 0
mmap(NULL, 2184192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbbf94000
mprotect(0x7f2cbbfa9000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbc1a8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f2cbc1a8000
close(3) = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P%\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2173512, ...}) = 0
mmap(NULL, 3981792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbbbc7000
mprotect(0x7f2cbbd8a000, 2093056, PROT_NONE) = 0
mmap(0x7f2cbbf89000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c2000) = 0x7f2cbbf89000
mmap(0x7f2cbbf8f000, 16864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2cbbf8f000
close(3) = 0
open("/lib64/libtinfo.so.5", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\316\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=174576, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd219000
mmap(NULL, 2268928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2cbb99d000
mprotect(0x7f2cbb9c2000, 2097152, PROT_NONE) = 0
mmap(0x7f2cbbbc2000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7f2cbbbc2000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd218000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd216000
arch_prctl(ARCH_SET_FS, 0x7f2cbd216740) = 0
mprotect(0x7f2cbbf89000, 16384, PROT_READ) = 0
mprotect(0x7f2cbbbc2000, 16384, PROT_READ) = 0
mprotect(0x7f2cbc1a8000, 4096, PROT_READ) = 0
mprotect(0x7f2cbc4aa000, 4096, PROT_READ) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd215000
mprotect(0x7f2cbc794000, 32768, PROT_READ) = 0
mprotect(0x7f2cbcbdc000, 4096, PROT_READ) = 0
mprotect(0x7f2cbc9d8000, 4096, PROT_READ) = 0
mprotect(0x7f2cbcffc000, 4096, PROT_READ) = 0
mprotect(0x7f2cbcde4000, 4096, PROT_READ) = 0
mprotect(0x7f2cbd223000, 4096, PROT_READ) = 0
munmap(0x7f2cbd21c000, 22349) = 0
set_tid_address(0x7f2cbd216a10) = 5039
set_robust_list(0x7f2cbd216a20, 24) = 0
rt_sigaction(SIGRTMIN, {0x7f2cbcdec7e0, [], SA_RESTORER|SA_SIGINFO, 0x7f2cbcdf56d0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7f2cbcdec870, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f2cbcdf56d0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL) = 0xa6f000
brk(0xa90000) = 0xa90000
brk(NULL) = 0xa90000
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
dup(1) = 3
close(3) = 0
stat("/etc/my.cnf", 0x7ffe45e970f0) = -1 ENOENT (No such file or directory)
stat("/etc/mysql/my.cnf", 0x7ffe45e970f0) = -1 ENOENT (No such file or directory)
stat("/usr/local/mysql/etc/my.cnf", 0x7ffe45e970f0) = -1 ENOENT (No such file or directory)
stat("/root/.my.cnf", 0x7ffe45e970f0) = -1 ENOENT (No such file or directory)
stat("/root/.mylogin.cnf", 0x7ffe45e970f0) = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2cbd221000
write(1, "/usr/local/mysql/bin/mysql would"..., 81/usr/local/mysql/bin/mysql would have been started with the following arguments:
) = 81
write(1, "\n", 1
) = 1
exit_group(0) = ?
+++ exited with 0 +++

临时不退出方法:

mysql> prompt (\u@\h) [\d]>\_
PROMPT set to '(\u@\h) [\d]>\_'
(root@localhost) [(none)]>

(root@localhost:mysql3306.sock) [(none)]> prompt (\u@\h:\p) [\d]>\_
PROMPT set to '(\u@\h:\p) [\d]>\_'
(root@localhost:mysql3306.sock) [(none)]>

最终方法:

 考虑到官方文档中提示会读取到/etc/my.cnf和~/.my.cnf下的prompt,就容易联想到是不是mysql客户端就只能读取到默认路径下的[mysql]?

  继续做以下尝试:

[root@dd ~]# /usr/local/mysql/bin/mysql --verbose --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

[root@zstedu ~]# cat /etc/my.cnf
[mysql]
prompt=\\u@\\h:\\p [\\d]>
[root@zstedu ~]# mysql -S /tmp/mysql3306.sock -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.22-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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:mysql3306.sock [(none)]>

prompt不生效之解决的更多相关文章

  1. Git忽略规则及.gitignore规则不生效的解决办法

    在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改根目录中 .gitignore 文件的方法(如无,则需自己手工建立此文件).这个文件每一行保存了一个匹配的规则例如: # 此为注 ...

  2. .gitignore规则不生效的解决办法

    .gitignore规则不生效的解决办法 使用git 的时候,在.gitignore中已经添加了某个文件或者文件夹,但是使用git status还能看见该文件的修改提示--–说明.gitignore未 ...

  3. Git忽略规则和.gitignore规则不生效的解决办法

    Git忽略规则和.gitignore规则不生效的解决办法   Git忽略规则: 在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改根目录中 .gitignore 文件的方法(如果 ...

  4. weblogic下更改jsp不生效的解决办法

    1.删除user_projects\domains\base_domain(我自己的域名)\servers\AdminServer目录下的所有文件夹 一下为转载from:http://blog.itp ...

  5. git 如何忽略文件以及使用.gitignore 不生效的解决办法

    (1) git 如何忽略文件 在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改根目录中 .gitignore 文件的方法(如无,则需自己手工建立此文件).这个文件每一行保存了一 ...

  6. 【转载】Git忽略规则和.gitignore规则不生效的解决办法

    原文:https://www.cnblogs.com/zhangxiaoliu/p/6008038.html Git忽略规则: 在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改 ...

  7. discuz论坛后台部分设置更改之后,清除了缓存网站前台不更新不生效的解决办法

    discuz论坛后台部分设置更改之后,清除了缓存但网站前台不更新不生效的解决办法 在config/config_global.php  把  $_config['memory']['eaccelera ...

  8. 微信小程序警告设置 enable-flex 属性以使 flexbox 布局生效的解决办法

    微信小程序警告设置 enable-flex 属性以使 flexbox 布局生效的解决办法 具体情况: scroll-view 滚动,设置 display:flex 不生效并警告设置 enable-fl ...

  9. git忽略文件夹提交以及gitignore修改后不生效的解决办法

    1.在 .gitgnore 文件加入需要忽略的问价夹正则表达式: 在配置完以后提交代码,你可能会发现git忽略配置不生效! 解决办法,将缓存的文件重新添加一下即可 2.打开命令行,将下面三个命令复制粘 ...

随机推荐

  1. VMware一些概念

    物理机:真真实实存在的机器,有操作系统.内存.硬盘.网卡. 虚拟机:vmware虚拟出来的,和物理机一样有操作系统.内存.硬盘.网卡. 虚拟机的网络连接的桥接模式.NAT模式.仅主机模式简单解说:  ...

  2. ZOJ Problem Set - 1005

    注意,条件:B>=C .应考虑B=C的情况. #include<iostream> using namespace std; int A,B,C; void jugs(int a,i ...

  3. Spring boot + Jpa + Maven + Mysql 初级整合

    1.使用Idea创建spring boot工程的博客 https://www.cnblogs.com/black-spike/p/8017768.html 2.本篇博客参考网址 https://blo ...

  4. Java-Redis Serializable序列化

    在Java中使用redis存储User对象时,进行JUnit测试时,控制台: 2019-06-24 16:56:45.520 INFO 27688 --- [ main] j.LocalContain ...

  5. Springboot使用launch.script打包后解压缩

    今天拿到一个SpringBoot的jar需要反编译看一下.直接用工具试了下提示报错. 于是用文本工具打开看了下,发现此JAR包在打包时候引入了启动脚本.如下图: 为了反编译,可以直接将所有启动脚本相关 ...

  6. PAT A1001 A+B Format (20 分)

    AC代码 #include <cstdio> #include <algorithm> using namespace std; const int maxn = 11; in ...

  7. Cow and Snacks(吃点心--图论转换) Codeforces Round #584 - Dasha Code Championship - Elimination Round (rated, open for everyone, Div. 1 + Div. 2)

    题意:https://codeforc.es/contest/1209/problem/D 有n个点心,有k个人,每个人都有喜欢的两个点心,现在给他们排个队,一个一个吃,每个人只要有自己喜欢的点心就会 ...

  8. T100 —— 凭证打印时排序

    capr110_g01,按扣账日期打印排序: 在adzp188——“字段”中加入pmds001的话,产生的代码的变量是:pmds_t_pmds001 :当在“群组”—“印出排序” 再添加pmds001 ...

  9. hdu 6025(女生赛)

    典型的用空间换取时间的思想 关键要理解多个数怎么算最小公倍数 用一个前缀 一个后缀 然后枚举去掉的点就可以了 #include <iostream> #include <cstdio ...

  10. curl 的使用

    curl 的使用 作者:与蟒唯舞链接:https://www.jianshu.com/p/f05bbd5007d9 curl 是一种命令行工具,作用是发出网络请求,然后获取数据,显示在"标准 ...