Use ctrl + w to delete a word with MySQL Cli

By default, and while you’re using mysql CLI the combination ctrl + w delete the enter line, so if you type a long query and you want to delete the word before the cursor the combination ctrl + w will not work and you have to use the backspace instead, and the only configuration to solve this problem is by creating the file ~/.editrc if it doesn’t exist and add this line of code:

bind "^W" ed-delete-prev-word

How to access the MySQL CLI With MAMP

First, you’ve to start MAMP or MAMP PRO, and you open your terminal and type:

/Applications/MAMP/Library/bin/mysql -uroot -p

Enter the password, by default the password, is root:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 254
Server version: 5.6.35 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>

If you want to use the command mysql by default without typing the entire command line you can edit one of these dot files ~./bashrc if you’re using bash or ~/.zshrc in case of using zsh and add this alias:

alias mysql=/Applications/MAMP/Library/bin/mysql -uroot -proot

After editing the file using Vim or Nano save the dot file, and run the source to validate the modification:

If you use zsh:

source ~/.zshrc

If you use bash:

source ~/.bashrc

Now you can run the command mysql from the terminal without typing any extra word.