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
+21.8k Golang : Encrypt and decrypt data with TripleDES
+5.5k How to check with curl if my website or the asset is gzipped ?
+33.1k Golang : How to check if a date is within certain range?
+26.8k Golang : How to check if a connection to database is still alive ?
+35.4k Golang : Strip slashes from string example
+32.9k Golang : Regular Expression for alphanumeric and underscore
+30.5k Golang : How to verify uploaded file is image or allowed file types
+25.4k Golang : Storing cookies in http.CookieJar example
+31.7k Golang : bufio.NewReader.ReadLine to read file line by line
+6k Golang : Detect variable or constant type
+18k Golang : How to make a file read only and set it to writable again?
+6.2k Golang : How to write backslash in string?