Setting up Vim SQL Workbench on MacOS

Nov. 16, 2019

This serves as my guide in case I would have to do it again, like when a clean OS reinstall is needed. This guide is for MacOS Mojave.

Here are the apps I installed:

  • MacVim v161 using dmg installer
  • SQLWorkBenchJ build 124 using dmg installer
  • MySQL 5.6 using brew
  • vim-sql-workbench using git clone

After following the official vim-sql-workbench documentation, I ended up with these lines in my .vimrc:

let g:sw_config_dir = '/Users/username/.sqlworkbench/'
let g:sw_exe = '/Applications/'
let g:sw_cache = '/Users/username/.cache/sw/'

The 2nd line is a result of following this guide here. In summary, I downloaded, unzipped it, then copied the file to that directory as above.

After copying into its final directory, run:

chmod +x

Edit this file by modifying line 4 from:
SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"
SCRIPT_PATH="$(dirname "$(greadlink -f "$0")")"

Install coreutils as mentioned here using command "brew install coreutils".

To connect, download the latest jdbc connector, then execute this in the buffer:

For MySQL:
WbConnect -url=jdbc:mysql://localhost:3306/mysql -driverJar=/Users/username/Documents/Apps/mysql-connector-java-8.0.18.jar -username=username -password=;

For Oracle:
WbConnect -url=jdbc:oracle:thin:@//localhost:1521/myschema -username=username -password=;

I'm still getting this error every time I connect to a MySQL database:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.