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"
Example:
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.
Please also remember that the default mode of MySQL Shell can be changed by executing the following.
mysqlsh
js> \option –persist defaultMode sql
The –persist works with all options listed on https://dev.mysql.com/doc/mysql-shell/8.3/en/mysql-shell-configuring-options.html , e.g. history.autoSave which I always turn on on my development machines.