Database Basic Information Collector
This collector gathers basic database information, including the database version, character set, database size, performance metrics, some database configurations, table object statistics (including the data types used by tables, data types of primary key fields, information about tables without primary keys, LOB table information, large data table information, and partitioned table and large partition information), and schema statistics.
Constraints
Only MySQL databases are supported. The database port (3306 by default) must be enabled on the firewalls of the database instances to be collected.
Parameters
Parameter |
Mandatory |
Configuration |
---|---|---|
db_instance_name |
No |
Specify the initial database name to connect to. For MySQL, the default is mysql. |
output_path |
No |
Specify a path for storing the output file of the collection results. For example, C:\MgC-Agent\test. The default path is C:\MgC-Agent\data\collection-result\ agent_collector_database_all_basic_info. |
user_selector |
No |
Specify the schemas or databases to be collected. Use commas (,) to separate multiple schemas or databases. This parameter is left empty by default, indicating that all schemas or databases on the database instance are collected. |
Granting Permissions in MySQL
To gather information from a database, the collector must connect to the database and query system views. This requires that the credential you provide have the required permissions. You can perform the following steps to obtain these permissions.
- Log in to the database server. Open the terminal (Linux) or command prompt (Windows), and access the MySQL client installation directory or configure MySQL environment variables. Run the following command to log in to the database:
mysql -u <user> -p
<user> indicates the database username. The user must have the permissions to create users and grant permissions. Generally, only the database administrator (for example, the root user) has these permissions. You are advised to contact the database administrator to perform the operations below.
Figure 1 MySQL CLI - After logging in to the database, run the following command to create a user:
CREATE USER <db-user>@<host> IDENTIFIED BY <db-password>;
- <db-user> indicates the username, which will be provided to the MgC Agent.
- <host> indicates specify the server used for login. You can omit @<host>. If it is omitted, the default value @% is used. You can specify the IP address of the MgC Agent server here. Examples:
- %: allows login from any server (including remote login).
- localhost: allows login only from the database server.
- 192.168.1.%: allows login from servers in a specified network segment (for example, 192.168.1.x).
- 192.168.1.252: allows login only from the server 192.168.1.252.
- <db-password> indicates the password of the user indicated by <db-user>. The password will be provided to the MgC Agent.
- Grant database permissions. You can grant permissions on a specified database or all databases based on your requirements.
- Run the following command to grant permissions on a specified database. The collector uses the MySQL database by default to test the connection. If the following permissions are not granted, the connection test fails.
GRANT SELECT ON mysql.* TO <db-user>@<host>; GRANT PROCESS ON *.* TO <db-user>@<host>; GRANT SELECT ON <database-name>.* TO <db-user>@<host>;
The PROCESS permission allows a user to view all tables in information_schema.
<db-user> indicates the username of the user created in 2.
@<host> specifies the server used for login. The value must be the same as that specified in step 2. If this parameter is left empty, the default value @% is used.
<database-name> indicates the name of the database from which data is to be collected.
- Run the following command to grant permissions on all databases:
GRANT PROCESS ON *.* TO <db-user>@<host>; GRANT SELECT ON *.* TO <db-user>@<host>;
<db-user> indicates the username of the user created in 2.
@<host> specifies the server used for login. The value must be the same as that specified in step 2. If this parameter is left empty, the default value @% is used.
- Run the following command to grant permissions on a specified database. The collector uses the MySQL database by default to test the connection. If the following permissions are not granted, the connection test fails.
- Run the following command to reload permissions:
FLUSH PRIVILEGES;
- Run the following command to check whether the user has the permissions:
SHOW GRANTS FOR <db-user>@<host>;
<db-user> indicates the username of the user created in 2.
@<host> specifies the server used for login. The value must be the same as that specified in step 2. If this parameter is left empty, the default value @% is used.
- Add the credential on the MgC Agent console.
- Log in to the MgC Agent console, access the Credentials page, and click Add Credential.
- On the displayed page, set Resource Type to Database and Authentication to User name/Password. Enter the username and password of the user created in 2.
Removing Permissions and Deleting a User in MySQL
- Run the REVOKE command to revoke the granted permissions. The syntax of the REVOKE command is the same as that of the GRANT command. Run the following commands as required to revoke the granted permissions:
REVOKE PROCESS ON *.* FROM <db-user>@<host>; REVOKE SELECT ON *.* FROM <db-user>@<host>; REVOKE SELECT ON mysql.* FROM <db-user>@<host>; REVOKE SELECT ON <database-name>.* TO <db-user>;
- Run the following command to delete the user:
DROP USER <db-user>@<host>;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot