Database management in Managed Service for MySQL
You can add and remove databases, view information about them, and manage some database settings using Managed Service for MySQL interfaces.
Warning
You can't manage databases using SQL commands. However, you can perform the ALTER DATABASE
operation.
Getting a list of cluster databases
- Go to the folder page
and select Managed Service for MySQL. - Click the cluster name and select the Databases tab.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To get a list of databases in a cluster, run the command:
ncp managed-mysql database list \
--cluster-name=<cluster name>
The cluster name can be requested with a list of clusters in the folder.
Creating a database
Note
You can create a maximum of 1000 databases in each cluster.
-
Go to the folder page
and select Managed Service for MySQL. -
Click the name of the cluster you need.
-
If the new database does not have an owner among its current users, add such a user.
-
Select the Databases tab.
-
Click Add.
-
Enter the database name and click Add.
A database name may contain letters, numbers, and underscores. The name may be up to 63 characters long. Such names as
mysql
,sys
,information_schema
, andperformance_schema
are reserved for Managed Service for MySQL. You cannot create DBs with these names. -
Grant privileges for access to the database created to the appropriate cluster users.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To create a database in a cluster:
-
View a description of the CLI create database command:
ncp managed-mysql database create --help
-
Run the create database command:
ncp managed-mysql database create <database name> --cluster-name=<cluster name>
A database name may contain letters, numbers, and underscores. The name may be up to 63 characters long. Such names as
mysql
,sys
,information_schema
, andperformance_schema
are reserved for Managed Service for MySQL. You cannot create DBs with these names.The cluster name can be requested with a list of clusters in the folder.
Managed Service for MySQL runs the create database operation.
Deleting a database
- Go to the folder page
and select Managed Service for MySQL. - Click the cluster name and open the Databases tab.
- Click the
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To delete a database, run the command:
ncp managed-mysql database delete <database name> --cluster-name=<cluster name>
The cluster name can be requested with a list of clusters in the folder.
Warning
Before creating a new database with the same name, wait for the delete operation to complete, otherwise the database being deleted will be restored. Operation status can be obtained with a list of cluster operations.
Setting SQL mode
You can set or change the value of the sql_mode setting that defines the SQL mode for the database. This operation restarts the cluster hosts.
- Go to the folder page
and select Managed Service for MySQL. - Select the cluster and click Edit cluster in the top panel.
- Under DBMS settings, click Settings.
- In the list of the settings, locate the sql_mode parameter.
- Configure a set of SQL modes in the drop-down list. To restore default settings, click Reset.
- Click Save in the DBMS settings dialog box.
- Click Save changes.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Set the SQL modes in the --set
parameter, for example:
ncp managed-mysql cluster update-config \
--name <cluster name> \
--set '"sql_mode=NO_KEY_OPTIONS,NO_TABLE_OPTIONS"'
Pay close attention to quotation marks: the entire string must constitute the parameter value, including sql_mode=
.
The cluster name can be requested with a list of clusters in the folder.
Changing a character set and collation rules
To set the CHARACTER SET
and COLLATE
settings for the database:
-
Connect to the database under the account of the database owner or as a user with the
ALTER
privilege for this database. -
Run the ALTER DATABASE
query:ALTER DATABASE <DB name> CHARACTER SET = 'utf8mb4' COLLATE = 'utf8mb4_unicode_ci';
-
To apply settings to the database tables along with the database, convert the tables with the same settings:
ALTER TABLE <DB name>.<table name> CONVERT TO CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';