Always use MySQL Shell

You know how much I praise and like MySQL Shell but if like me, for you too, old habits die hard, I advise you to create these different aliases in your ~/.bashrc (or ~/.bash_aliases) file to force yourself to use MySQL Shell even for a small statement check:

alias mysql="mysqlsh --sql mysql://localhost"
alias mysqlx="mysqlsh --js mysqlx://localhost"

Of course you can specify the user you want, by default it uses the same user as the system one.

For example, if this is your test machine and you want to always use the root account (even if not recommended), you can specify it like this by modifying the URI:

alias mysql="mysqlsh --sql mysql://root@localhost"


So now when using mysql MySQL Shell is launched and it connects directly to localhost in SQL mode using the classic protocol.

With mysqlx command, This time MySQL Shell is started and connects to localhost using the X Protocol and my session is now in JavaScript mode:

Two easy aliases to get rid of using the old mysql client in my terminal.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

One comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.