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?

2 Answers 2


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> '

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

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


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.

  • sorry, but I want the prompt to follow some mysql variables. I just don't know what the variable will be BEFORE I launch mysql or mariadb, but it may change often during working sessions.
    – dominix
    Mar 31, 2017 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.