prompt不生效之解决

当MySQL客户端的prompt设置不生效时,问题可能出在配置文件路径上。通过检查配置文件`/etc/my.cnf`并添加或修改prompt选项可以解决。将prompt设置为`\u@\h:\p [\d]>`,然后重启服务或重新连接,确认prompt是否正常显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

配置文件路径:

/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) =

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值