@@ -5,7 +5,7 @@ ms.service: mariadb
5
5
author : savjani
6
6
ms.author : pariks
7
7
ms.topic : how-to
8
- ms.date : 06/24/2022
8
+ ms.date : 04/19/2023
9
9
ms.devlang : csharp, golang, java, php, python, ruby
10
10
ms.custom : devx-track-csharp
11
11
---
@@ -40,7 +40,7 @@ For existing connections, you can bind SSL by right-clicking on the connection i
40
40
41
41
Another way to bind the SSL certificate is to use the MySQL command-line interface by executing the following commands.
42
42
43
- ``` bash
43
+ ``` terminal
44
44
mysql.exe -h mydemoserver.mariadb.database.azure.com -u Username@mydemoserver -p --ssl-mode=REQUIRED --ssl-ca=c:\ssl\BaltimoreCyberTrustRoot.crt.pem
45
45
```
46
46
@@ -57,16 +57,19 @@ Using the Azure portal, visit your Azure Database for MariaDB server, and then s
57
57
### Using Azure CLI
58
58
59
59
You can enable or disable the ** ssl-enforcement** parameter by using Enabled or Disabled values respectively in Azure CLI.
60
+
60
61
``` azurecli-interactive
61
62
az mariadb server update --resource-group myresource --name mydemoserver --ssl-enforcement Enabled
62
63
```
63
64
64
65
## Verify the SSL connection
65
66
66
67
Execute the mysql ** status** command to verify that you have connected to your MariaDB server using SSL:
68
+
67
69
``` sql
68
70
status
69
71
```
72
+
70
73
Confirm the connection is encrypted by reviewing the output, which should show: ** SSL: Cipher in use is AES256-SHA**
71
74
72
75
## Sample code
@@ -83,6 +86,7 @@ if (mysqli_connect_errno($conn)) {
83
86
die('Failed to connect to MySQL: '.mysqli_connect_error());
84
87
}
85
88
```
89
+
86
90
### Python (MySQLConnector Python)
87
91
88
92
``` python
95
99
except mysql.connector.Error as err:
96
100
print (err)
97
101
```
102
+
98
103
### Python (PyMySQL)
99
104
100
105
``` python
@@ -117,6 +122,7 @@ client = Mysql2::Client.new(
117
122
:ssl_mode => ' required'
118
123
)
119
124
```
125
+
120
126
#### Ruby on Rails
121
127
122
128
``` ruby
@@ -142,6 +148,7 @@ var connectionString string
142
148
connectionString = fmt.Sprintf (" %s :%s @tcp(%s :3306)/%s ?allowNativePasswords=true&tls=custom" ,' myadmin@mydemoserver' , ' yourpassword' , ' mydemoserver.mariadb.database.azure.com' , ' quickstartdb' )
143
149
db , _ := sql.Open (" mysql" , connectionString)
144
150
```
151
+
145
152
### Java (JDBC)
146
153
147
154
``` java
@@ -172,6 +179,7 @@ properties.setProperty("user", 'myadmin@mydemoserver');
172
179
properties. setProperty(" password" , ' yourpassword' );
173
180
conn = DriverManager . getConnection(url, properties);
174
181
```
182
+
175
183
### Java (MariaDB)
176
184
177
185
``` java
0 commit comments