Bug #78767 Support customizing the welcome message for the mysql command line client
Submitted: 8 Oct 2015 22:30 Modified: 8 Oct 2015 22:31
Reporter: Jesper wisborg Krogh Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[8 Oct 2015 22:30] Jesper wisborg Krogh
Description:
The current welcome message for the mysql command line client is hard coded to:

     Welcome to the MySQL monitor.  Commands end with ; or \g.

followed by the connection id and copyright notice.

It would be good to allow customizing this message.

How to repeat:
See the source code:

The welcome message is generated in client/mysql.cc:

...
int main(int argc,char *argv[])
{
...
 put_info("Welcome to the MySQL monitor.  Commands end with ; or \\g.",
  INFO_INFO);
 my_snprintf((char*) glob_buffer.ptr(), glob_buffer.alloced_length(),
  "Your MySQL connection id is %lu\nServer version: %s\n",
  mysql_thread_id(&mysql), server_version_string(&mysql));
 put_info((char*) glob_buffer.ptr(),INFO_INFO);

 put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"), INFO_INFO);
...

int put_info is defined in the same file:

...
static int put_info(const char *str,INFO_TYPE info,uint error=0,
   const char *sql_state=0);
...
static int
put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
{
...
 if (!opt_silent || info_type == INFO_ERROR)
 {
...

So the message is hard coded and only the silent option affects it. 

Suggested fix:
A few options exists:

1. Let the server push it through to the client. This will have the advantage that you always get the server specific message no matter which client you connect with and it doesn't allow the client to overwrite the message.

2. A mysql command line client option. The advantage is that each user can set their own header, but the disadvantage is that the DBA doesn't control it.
[8 Oct 2015 22:36] Jesper wisborg Krogh
Posted by developer:
 
For some use cases setting the prompt may work as a workaround:

http://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html#option_mysql_prompt
[24 Jan 2019 11:28] Bert de Jong
I would also like to customize it, to add instructions and information specific to our organization.