title: How can I switch between connections in MySQL CLI?
body: <p>I am following this tutorial <a href="https://docs.microsoft.com/en-us/azure/mysql/quickstart-create-mysql-server-database-using-azure-cli" rel="nofollow noreferrer">Create MySQL Server Database with Azure</a>. I successfully created a connection; my problem is that when I use the mysql cli, I connect to the localhost connection, rather than the Azure connection. Is there a command that would let me choose which connection I want to work with in the cli?? Sorry if this is too obvios, but I couldn't get to a source that demonstrated how to do that. If this is a duplicate question, kindly express why and point me to a straightforward answer of the same issue and I will delete this one. Thanks!!</p>
  
  <p>I tried the command "\connect azure-XXXX@mysql-azure-XXXX" but I get "->" like nothing happened, then typed "status" and still shows my localhost connection. Basically I have two active connections. When I turn off my localhost connection and try to check the status of my active "azure" connection, then I get the error " Lost connection to MySQL server during query"</p>
  
  <p><code>mysql&gt; status</code></p>
  
  <pre><code>86_64 (MySQL Community Server - GPL)
  
  Connection id:          10
  Current database:
  Current user:           root@localhost
  SSL:                    Cipher in use is DHE-RSA-xxxxxxxx
  Using delimiter:        ;
  Server version:         8.0.17 MySQL Community Server - GPL
  Protocol version:       10
  Connection:             localhost via TCP/IP
  Server characterset:    xxxx
  Db     characterset:    xxxx
  Client characterset:    xxx
  Conn.  characterset:    xxx
  TCP port:               3306
  Uptime:                 18 hours 17 min 6 sec
  
  Threads: 2  Questions: 11  Slow queries: 0  Opens: 115  Flush tables: 3  Open t
  bles: 35  Queries per second avg: 0.000
  </code></pre>
  
  <p>this is what I am trying to get to:</p>
  
  <pre><code>Enter password: ***********
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 65512
  Server version: 5.6.26.0 MySQL Community Server (GPL)
  
  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.
  
  mysql&gt; status
  --------------
  mysql  Ver 14.14 Distrib 5.6.35, for Win64 (x86_64)
  
  Connection id:          65512
  Current database:
  Current user:           myadmin@116.230.243.143
  SSL:                    Not in use
  Using delimiter:        ;
  Server version:         5.6.26.0 MySQL Community Server (GPL)
  Protocol version:       10
  Connection:             mydemoserver.mysql.database.azure.com via TCP/IP
  Server characterset:    latin1
  Db     characterset:    latin1
  Client characterset:    gbk
  Conn.  characterset:    gbk
  TCP port:               3306
  Uptime:                 2 days 9 hours 47 min 20 sec
  
  Threads: 4  Questions: 34833  Slow queries: 2  Opens: 84  Flush tables: 4  Open tables: 1  Queries per second avg: 0.167
  --------------
  
  mysql&gt;
  </code></pre>