Jonjilla Jonjilla - 1 month ago 14
MySQL Question

julia mysql.jl use non default port

I'm trying to connect to a MySQL database using the mySQl.jl package. it seems to work fine when I'm using the standard mySQL port 3306, but I don't see where to specify a database on a different port. How is that accomplished?

Answer Source

From the help doc of mysql_connect (get it with ?mysql_connect at the REPL):

mysql_connect(host::String, user::String, passwd::String, 
  db::String = ""; port::Int64 = MYSQL_DEFAULT_PORT, 
  socket::String = MYSQL_DEFAULT_SOCKET, opts = Dict()) 

Connect to a MySQL database.

So just add a named parameter port= after the database name parameter. For example:

mysql_connect("localhost", "john", "password", "my_db", port=1234)