I am trying to write a program to connect with the cPanel MySQL database.
When writing the connection string I used the below syntax.
string connStr = "server=localhost;user=mywebsite_root;database=online_database;port=3306;password='123456'";
In first place I tried this on localhost then after switch to online.
I have used the port 3306 to connect with the localserver.
But not sure which port do I need to use to connect with the cPanel database.
when I removed the port section from the above line it's not saving the data properly to the cPanel database.
Any suggestions?
It is commonly 3306
But you can check out certainly at the header of PhpMyAdmin.
Follow these steps: Go to your CPanel Database section Click on PhpMyAdmin
Now, look at You will see "localhost:port". That is the port you should put in
DB_PORT
at your .env file.
Just in case you don't know, the DB_HOST
must be your Host IP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.