Golang : What is the default port number for connecting to MySQL/MariaDB database ?
Problem :
How to determine which port number when trying to connect to a database with https://github.com/go-sql-driver/mysql and configuring the data source name.
conn, err := sql.Open("mysql", "db_username:db_password@protocol(address:port_num)/database_name")
Need to find out the port_num portion.
Solution :
The default port number to connect to MySQL or MariaDB is 3306
. Got this from looking at the PHPMyAdmin's configuration file.
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+9.3k Golang : Scramble and unscramble text message by randomly replacing words
+19.4k Golang : How to Set or Add Header http.ResponseWriter?
+4.7k Which content-type(MIME type) to use for JSON data
+27.9k Golang : Move file to another directory
+22k Golang : How to run Golang application such as web server in the background or as daemon?
+14.2k Golang : Recombine chunked files example
+18.3k Golang : Aligning strings to right, left and center with fill example
+8.9k Golang : Handle sub domain with Gin
+18.5k Golang : Implement getters and setters
+15.6k Golang : Get digits from integer before and after given position example
+5.6k Unix/Linux/MacOSx : Get local IP address
+6.9k Golang : Takes a plural word and makes it singular