Skip to content

Commit f6854e6

Browse files
authored
Merge pull request #188997 from mksuni/mysql-flex-databases
Article to manage mysql flexible server databases in portal
2 parents b5ac38c + 9929f57 commit f6854e6

File tree

7 files changed

+74
-44
lines changed

7 files changed

+74
-44
lines changed

articles/mysql/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
- name: ARM template
4141
displayName: Resource Manager
4242
href: flexible-server/quickstart-create-arm-template.md
43+
- name: Create and manage databases
44+
href: flexible-server/how-to-create-manage-databases.md
4345
- name: Connect and query
4446
items:
4547
- name: Azure CLI

articles/mysql/concepts-query-store.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Use the [Azure portal](howto-server-parameters.md) or [Azure CLI](howto-confi
104104

105105
## Views and functions
106106

107-
View and manage Query Store using the following views and functions. Anyone in the [select privilege public role](howto-create-users.md#to-create-more-admin-users-in-azure-database-for-mysql) can use these views to see the data in Query Store. These views are only available in the **mysql** database.
107+
View and manage Query Store using the following views and functions. Anyone in the [select privilege public role](howto-create-users.md) can use these views to see the data in Query Store. These views are only available in the **mysql** database.
108108

109109
Queries are normalized by looking at their structure after removing literals and constants. If two queries are identical except for literal values, they will have the same hash.
110110

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: How to create databases for Azure Database for MySQL Flexible Server
3+
description: This article describes how to create and manage databases on Azure Database for MySQL Flexible server.
4+
author: mksuni
5+
ms.author: sumuth
6+
ms.service: mysql
7+
ms.topic: how-to
8+
ms.date: 02/17/2022
9+
---
10+
11+
# Create and manage databases for Azure Database for MySQL Flexible Server
12+
13+
This article contains information about creating, listing, and deleting MySQL databases on Azure Database for Flexible Server.
14+
15+
## Prerequisites
16+
Before completing the tasks, you must have
17+
- Created an Azure Database for MySQL Flexible server using [Azure portal](./quickstart-create-server-portal.md) <br/> or [Azure CLI](./quickstart-create-server-cli.md).
18+
- Sign in to [Azure portal](https://portal.azure.com).
19+
20+
21+
## List your databases
22+
To list all your databases on MySQL flexible server:
23+
- Open the **Overview** page of your MySQL flexible server.
24+
- Select **Databases** from the settings on left navigation menu.
25+
26+
> :::image type="content" source="media/how-to-create-manage-databases/databases-view-mysql-flexible-server.png" alt-text="Screenshot showing how to list all the databases on Azure Database for MySQL flexible server":::
27+
28+
## Create a database
29+
To create a database on MySQL flexible server:
30+
31+
- Select **Databases** from the settings on left navigation menu.
32+
- Click on **Add** to create a database. Provide the database name, charset and collation settings for this database.
33+
- Click on **Save** to complete the task.
34+
35+
> :::image type="content" source="media/how-to-create-manage-databases/create-database-azure-mysql-flexible-server.png" alt-text="Screenshot showing how to create a database on Azure Database for MySQL flexible server":::
36+
37+
## Delete a database
38+
To delete a database on MySQL flexible server:
39+
40+
- Select **Databases** from the settings on left navigation menu.
41+
- Click on **testdatabase1** to select the database. You can select multiple databases to delete at the same time.
42+
- Click on **Delete** to complete the task.
43+
44+
> :::image type="content" source="media/how-to-create-manage-databases/delete-database-on-mysql-flexible-server.png" alt-text="Screenshot showing how to delete a database on Azure Database for MySQL flexible server":::
45+
46+
## Next steps
47+
48+
Learn how to [manage users](../howto-create-users.md)
Loading
183 KB
Loading
228 KB
Loading

articles/mysql/howto-create-users.md

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
title: Create databases and users - Azure Database for MySQL
2+
title: How to create users for Azure Database for MySQL
33
description: This article describes how to create new user accounts to interact with an Azure Database for MySQL server.
44
author: savjani
55
ms.author: pariks
66
ms.service: mysql
77
ms.topic: how-to
8-
ms.date: 01/13/2021
8+
ms.date: 02/17/2022
99
---
1010

11-
# Create databases and users in Azure Database for MySQL
11+
# Create users in Azure Database for MySQL
1212

1313
[!INCLUDE[applies-to-mysql-single-flexible-server](includes/applies-to-mysql-single-flexible-server.md)]
1414

15-
This article describes how to create users in Azure Database for MySQL.
15+
This article describes how to create users for Azure Database for MySQL.
1616

1717
> [!NOTE]
1818
> This article contains references to the term *slave*, a term that Microsoft no longer uses. When the term is removed from the software, we'll remove it from this article.
@@ -30,87 +30,67 @@ After you create an Azure Database for MySQL server, you can use the first serve
3030
>
3131
> Password plugins like `validate_password` and `caching_sha2_password` aren't supported by the service.
3232
33-
## To create a database with a non-admin user in Azure Database for MySQL
33+
## Create a database
3434

3535
1. Get the connection information and admin user name.
3636
To connect to your database server, you need the full server name and admin sign-in credentials. You can easily find the server name and sign-in information on the server **Overview** page or on the **Properties** page in the Azure portal.
3737

3838
2. Use the admin account and password to connect to your database server. Use your preferred client tool, such as MySQL Workbench, mysql.exe, or HeidiSQL.
3939

40-
If you're not sure how to connect, see [connect and query data for Single Server](./connect-workbench.md) or [connect and query data for Flexible Server](./flexible-server/connect-workbench.md).
40+
> [!NOTE]
41+
> If you're not sure how to connect, see [connect and query data for Single Server](./connect-workbench.md) or [connect and query data for Flexible Server](./flexible-server/connect-workbench.md).
4142
4243
3. Edit and run the following SQL code. Replace the placeholder value `db_user` with your intended new user name. Replace the placeholder value `testdb` with your database name.
4344

4445
This SQL code creates a new database named testdb. It then creates a new user in the MySQL service and grants all privileges for the new database schema (testdb.\*) to that user.
4546

4647
```sql
4748
CREATE DATABASE testdb;
49+
```
4850

51+
## Create a non-dmin user
52+
Now that the database is created , you can create with a non-admin user with the ``` CREATE USER``` MySQL statement.
53+
``` sql
4954
CREATE USER 'db_user'@'%' IDENTIFIED BY 'StrongPassword!';
5055

5156
GRANT ALL PRIVILEGES ON testdb . * TO 'db_user'@'%';
5257

5358
FLUSH PRIVILEGES;
5459
```
5560

56-
4. Verify the grants in the database:
61+
## Verify the user permissions
62+
Run the ```SHOW GRANTS``` MySQL statement to view the privileges allowed for user **db_user** on **testdb** database.
5763

5864
```sql
5965
USE testdb;
6066

6167
SHOW GRANTS FOR 'db_user'@'%';
6268
```
6369

64-
5. Sign in to the server, specifying the designated database and using the new user name and password. This example shows the mysql command line. When you use this command, you'll be prompted for the user's password. Use your own server name, database name, and user name.
65-
66-
### [Single Server](#tab/single-server)
70+
## Connect to the database with new user
71+
Sign in to the server, specifying the designated database and using the new user name and password. This example shows the mysql command line. When you use this command, you'll be prompted for the user's password. Use your own server name, database name, and user name. See how to connect for Single server and Flexible server below.
6772

68-
```azurecli-interactive
69-
mysql --host mydemoserver.mysql.database.azure.com --database testdb --user db_user@mydemoserver -p
70-
```
71-
72-
### [Flexible Server](#tab/flexible-server)
73+
| Server type | Usage |
74+
| ----------- | ----------- |
75+
| Single Server | ```mysql --host mydemoserver.mysql.database.azure.com --database testdb --user db_user@mydemoserver -p``` |
76+
| Flexible Server | ``` mysql --host mydemoserver.mysql.database.azure.com --database testdb --user db_user -p```|
7377

74-
```azurecli-interactive
75-
mysql --host mydemoserver.mysql.database.azure.com --database testdb --user db_user -p
76-
```
7778

78-
## To create more admin users in Azure Database for MySQL
79-
80-
1. Get the connection information and admin user name.
81-
To connect to your database server, you need the full server name and admin sign-in credentials. You can easily find the server name and sign-in information on the server **Overview** page or on the **Properties** page in the Azure portal.
82-
83-
2. Use the admin account and password to connect to your database server. Use your preferred client tool, such as MySQL Workbench, mysql.exe, or HeidiSQL.
84-
85-
If you're not sure how to connect, see [Use MySQL Workbench to connect and query data](./connect-workbench.md).
86-
87-
3. Edit and run the following SQL code. Replace the placeholder value `new_master_user` with your new user name. This syntax grants the listed privileges on all the database schemas (*.*) to the user (`new_master_user` in this example).
79+
## Limit privileges for user
80+
To restrict the type of operations a user can run on the database, you need to explicitly add the operations in the **GRANT** statement. See an example below:
8881

8982
```sql
9083
CREATE USER 'new_master_user'@'%' IDENTIFIED BY 'StrongPassword!';
9184

9285
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'new_master_user'@'%' WITH GRANT OPTION;
9386

94-
FLUSH PRIVILEGES;
95-
```
96-
97-
4. Verify the grants:
98-
99-
```sql
100-
USE sys;
101-
102-
SHOW GRANTS FOR 'new_master_user'@'%';
87+
FLUSH PRIVILEGES;
10388
```
10489

105-
## azure_superuser
90+
## About azure_superuser
10691

10792
All Azure Database for MySQL servers are created with a user called "azure_superuser". This is a system account created by Microsoft to manage the server to conduct monitoring, backups, and other regular maintenance. On-call engineers may also use this account to access the server during an incident with certificate authentication and must request access using just-in-time (JIT) processes.
10893

10994
## Next steps
11095

111-
Open the firewall for the IP addresses of the new users' machines to enable them to connect:
112-
113-
* [Create and manage firewall rules on Single Server](howto-manage-firewall-using-portal.md)
114-
* [Create and manage firewall rules on Flexible Server](flexible-server/how-to-connect-tls-ssl.md)
115-
11696
For more information about user account management, see the MySQL product documentation for [User account management](https://dev.mysql.com/doc/refman/5.7/en/access-control.html), [GRANT syntax](https://dev.mysql.com/doc/refman/5.7/en/grant.html), and [Privileges](https://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html).

0 commit comments

Comments
 (0)