MySQL equivalent of PostgreSQL’s psql c command

Posted on

Question :

I’m learning PostgreSQL though oddly enough figured out to switch users while in the psql command line to use c database username; what is the equivalent to switch from one user to another in MySQL’s command prompt?

Answer :

In the context of MySQL, you cannot switch users. You can switch database and host.

According to the MySQL Documentation on the MySQL Client

connect [db_name host_name]], r [db_name host_name]]

Reconnect to the server. The optional database name and host name arguments may be given to specify the default database or the host where the server is running. If omitted, the current values are used.

This looks similar to how PostgreSQL does it.

Leave a Reply

Your email address will not be published. Required fields are marked *