本篇内容介绍了“mysql提示符的修改过程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

㈠ 在 Bash 层修改 MYSQL_PS1 变量

root@localhost ~]# export MYSQL_PS1="(\u@\h) [\d]> "

[root@localhost~]#mysql-uroot-pEnterpassword:WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis73Serverversion:5.5.28MySQLCommunityServer(GPL)Copyright(c)2000,2012,Oracleand/oritsaffiliates.Allrightsreserved.OracleisaregisteredtrademarkofOracleCorporationand/oritsaffiliates.Othernamesmaybetrademarksoftheirrespectiveowners.Type\'help;\'or\'\h\'forhelp.Type\'\c\'toclearthecurrentinputstatement.(root@localhost)[(none)]>usetest;Databasechanged(root@localhost)[test]>

㈡ MySQL 命令行参数

[root@localhost~]#mysql-uroot-p--prompt="(\u@\h)[\d]>"Enterpassword:WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis74Serverversion:5.5.28MySQLCommunityServer(GPL)Copyright(c)2000,2012,Oracleand/oritsaffiliates.Allrightsreserved.OracleisaregisteredtrademarkofOracleCorporationand/oritsaffiliates.Othernamesmaybetrademarksoftheirrespectiveowners.Type\'help;\'or\'\h\'forhelp.Type\'\c\'toclearthecurrentinputstatement.(root@localhost)[(none)]>

㈢ 配置文件 /etc/my.cnf

[mysql]prompt=(\\u@\\h)[\\d]>\\_又或者:[mysql]prompt="\\r:\\m:\\s>"要多加一个反斜线\.

㈣ 在 MySQL 中使用 prompt 命令

mysql>prompt\r:\m:\s\P>\_PROMPTsetto\'\r:\m:\s\P>\_\'08:20:42pm>promptReturningtodefaultPROMPTofmysql>mysql>

附录:

OptionDescription\cAcounterthatincrementsforeachstatementyouissue\DThefullcurrentdate\dThedefaultdatabase\hTheserverhost\lThecurrentdelimiter(newin5.0.25)\mMinutesofthecurrenttime\nAnewlinecharacter\OThecurrentmonthinthree-letterformat(Jan,Feb,…)\oThecurrentmonthinnumericformat\Pam/pm\pThecurrentTCP/IPportorsocketfile\RThecurrenttime,in24-hourmilitarytime(0–23)\rThecurrenttime,standard12-hourtime(1–12)\SSemicolon\sSecondsofthecurrenttime\tAtabcharacter\UYourfulluser_name@host_nameaccountname\uYourusername\vTheserverversion\wThecurrentdayoftheweekinthree-letterformat(Mon,Tue,…)\YThecurrentyear,fourdigits\yThecurrentyear,twodigits\_Aspace\Aspace(aspacefollowsthebackslash)\\'Singlequote\"Doublequote\\Aliteral“\”backslashcharacter\xx,forany“x”notlistedabove

“mysql提示符的修改过程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!