DiegoOrbezo
DiegoOrbezo

Reputation: 23

Configure MySQL in SublimeText 3

I want to configure MySQL in SublimeText 3, I found that the configuration is from Build System / New Build System ...

My written code is as follows:

{
"cmd": ["C: /xampp/mysql/bin/mysql.exe", "-u", "dorbezo", "-P", "Dorbezo123", "-h", "192.168.1.99", " -e "," source $ file "," -t "],
"selector": "source.sql",
"quiet": true}

My credentials to access MySQL from Workbench are the following:

user: dorbezo, pass: Dorbezo123, host: port: 192.168.1.99:3306

Am I entering the connection correctly? It is worth mentioning that I connect via VPN and I have ** xampp ** started when I try to run a query, getting the following error:

** show databases; ** Unknown suffix 'D' used for variable 'port' (value 'Dorbezo123') C: /xampp/mysql/bin/mysql.exe: Error while setting value 'Dorbezo123' to 'port'

I also mention that the port where ** xampp ** connects is 3307, since 3306 (which I use in Workbench) causes me conflict.

Upvotes: 1

Views: 2826

Answers (1)

mattst
mattst

Reputation: 13980

There are several problems with your .sublime-build file.

  • Your command path "C: /xampp/mysql/bin/mysql.exe" has a space in it but perhaps that was pasted into your post incorrectly. I would have expected something more like this on Windows: "C:\\xampp\\mysql\\bin\\mysql.exe".

  • You are using an uppercase -P for your password, it should be a lowercase -p.

  • You possibly need to add the port number with the uppercase "-P", "3306". I say 'possibly' because 3306 is the default port for MySQL so you may not need to specify it at all.

  • Using long form options is generally a good idea because they prevent letter case mistakes. e.g. --user, --password, --host, --port, --execute, --table.

Here is a MySQL.sublime-build file for you to try, the long options (with my details) work for me on Linux:

{
    "cmd": ["C:\\xampp\\mysql\\bin\\mysql.exe", "--user=dorbezo", "--password=Dorbezo123", "--host=192.168.1.99", "--port=3306", "--execute=source $file", "--table"],
    "selector": "source.sql"
}

Clearly storing a password in a .sublime-build file is a security risk. You should consider creating a MySQL user with an insecure password which has limited privileges.

There is also the SQLTools Sublime Text plugin which you could install, see here for the documentation. Instead of your connection details being stored in a .sublime-build file you would add them in a SQLToolsConnections.sublime-settings settings file. The documentation link above has detailed examples. I suspect you might find using this plugin easier than managing the build file. Using this plugin means there is less of a password security issue; if you use null in the password field (not in quotes) then the plugin will prompt for the password and then remember it for the session (I think).

Upvotes: 1

Related Questions