标签:null reserve ade restore store arch var \n div
配置文件路径:
/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)]>
标签:null reserve ade restore store arch var \n div
原文地址:https://www.cnblogs.com/chinaops/p/9238649.html