I would like to change the prompt to my mariadb or mysql client.
I would like the prompt to be the contain of a variable like report_host
or more, to something that can change like default_master_connection
.
Does someone know how to do it?
I would like to change the prompt to my mariadb or mysql client.
I would like the prompt to be the contain of a variable like report_host
or more, to something that can change like default_master_connection
.
Does someone know how to do it?
AFAIK MySQL prompt cannot be set to MySQL variables (Global or Session). The only options that can be used are documented at https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html (look towards the end of the documentation page for a full list).
Several ways.
Set it manually:
mysql> prompt Foo>
PROMPT set to 'Foo> '
Foo>
Environment variable:
root@ironforge:~# export MYSQL_PS1="Foo> "
root@ironforge:~# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 195
Server version: 5.5.54-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2016, 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.
Foo>
You can also use variables to add things like the database name (\d
), hostname (\h
) etc to the prompt. A full list is available in the documentation.