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
+5.2k Golang : How to get capacity of a slice or array?
+11.9k Golang : Date and Time formatting
+25.6k Golang : Convert CSV data to JSON format and save to file
+3.6k MariaDB/MySQL : How to get version information
+11.6k Golang : Qt progress dialog example
+9.6k Golang : Generate random elements without repetition or duplicate
+8.8k Golang : Use regular expression to get all upper case or lower case characters example
+5.1k Golang : Debug with Godebug
+30.8k Golang : Smarter Error Handling with strings.Contains()
+9.3k Golang : How to delete element(data) from map ?
+8.6k Golang : Sort and reverse sort a slice of integers
+10.8k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard