Real people, 24/7(800) 395-7779

Database Connection String Examples (MSSQL and MySQL) for Windows Hosting Print

  • mssql, database connection, databases, connection string, MS SQL
  • 0

Here are connection string examples for applications on our Windows (Plesk) hosting. Our shared servers run Microsoft SQL Server 2017/2019 for MSSQL databases and MariaDB 10.6 for MySQL databases.

Find your values first:

  1. Log in to Plesk and click Databases.
  2. Click Connection Info next to your database. It shows the server name (host, plus instance name if there is one), the database name and the user.
  3. Replace SERVER, myDatabase, myUser and myPassword below with your own values.

Note: Use the server name exactly as Plesk shows it. Do not assume localhost or .\SQLEXPRESS. MSSQL uses a named instance on our servers, so include the instance name if Plesk shows one. The default port (1433) works.

MSSQL - ASP.NET (web.config):

<connectionStrings>
  <add name="DefaultConnection"
       connectionString="Server=SERVER;Database=myDatabase;User Id=myUser;Password=myPassword;"
       providerName="System.Data.SqlClient" />
</connectionStrings>

MSSQL - ASP.NET Core (appsettings.json):

"ConnectionStrings": {
  "DefaultConnection": "Server=SERVER;Database=myDatabase;User Id=myUser;Password=myPassword;TrustServerCertificate=True;"
}

Newer Microsoft.Data.SqlClient versions encrypt connections by default. If you get a certificate error, add TrustServerCertificate=True as shown.

MSSQL - Classic ASP (ADO):

Provider=MSOLEDBSQL;Server=SERVER;Database=myDatabase;Uid=myUser;Pwd=myPassword;

The Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL) is installed on our servers. For ODBC, use Driver={ODBC Driver 17 for SQL Server};Server=SERVER;Database=myDatabase;Uid=myUser;Pwd=myPassword;

MySQL / MariaDB - ASP.NET (MySql.Data or MySqlConnector):

Server=SERVER;Port=3306;Database=myDatabase;Uid=myUser;Pwd=myPassword;

MySQL / MariaDB - PHP (PDO):

$pdo = new PDO('mysql:host=SERVER;dbname=myDatabase;charset=utf8mb4', 'myUser', 'myPassword');

Microsoft Access (.mdb / .accdb):

Access databases are not supported on our Windows shared hosting (the Jet/ACE drivers are not installed). Move the data to MSSQL or MySQL/MariaDB, or use a Windows VPS.

Tips:

  • Database users are separate from your Plesk login. Create or reset them under Databases in Plesk.
  • More examples: connectionstrings.com.

Need help? Open a ticket at https://my.peopleshost.com/submitticket.php and our support team will be glad to assist.


Was this answer helpful?

« Back