Share via


How to generate an Azure Database for MariaDB connection string with PowerShell

Important

Azure Database for MariaDB is on the retirement path. We strongly recommend that you migrate to Azure Database for MySQL. For more information about migrating to Azure Database for MySQL, see What's happening to Azure Database for MariaDB?.

This article demonstrates how to generate a connection string for an Azure Database for MariaDB server. You can use a connection string to connect to an Azure Database for MariaDB from many different applications.

Requirements

This article uses the resources created in the following guide as a starting point:

Get the connection string

The Get-AzMariaDbConnectionString cmdlet is used to generate a connection string for connecting applications to Azure Database for MariaDB. The following example returns the connection string for a PHP client from mydemoserver.

Get-AzMariaDbConnectionString -Client PHP -Name mydemoserver -ResourceGroupName myresourcegroup
$con=mysqli_init();mysqli_ssl_set($con, NULL, NULL, {ca-cert filename}, NULL, NULL); mysqli_real_connect($con, "mydemoserver.mariadb.database.azure.com", "myadmin@mydemoserver", {your_password}, {your_database}, 3306);

Valid values for the Client parameter include:

  • ADO.NET
  • JDBC
  • Node.js
  • PHP
  • Python
  • Ruby
  • WebApp

Next steps