[Solved] Initial setup problems with connection to database

I ran into the similar issue
Connection string:

"DataSource": "mmuser:mmPassword@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s"

I was getting below error on command sudo -u mattermost ./bin/mattermost

Solution:
MySql was running on a different port on my system, it was running on port 6606 and not on 3306.

You can run the below commands to check the MySql port

cd /etc/mysql/mysql.conf.d
sudo nano mysqld.cnf

in the file mysqld.cnf you can look at the value for port

Correct connection string that worked for me then

"DataSource": "mmuser:mmPassword@tcp(localhost:6606)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s"