First of all, Dameng database and MySQL are two different relational database management systems, and they have the following differences:
- The development companies are different: Dameng database is developed by China Dameng Company, while MySQL is developed by Swedish MySQL AB.
- The database types are different: Dameng database is a commercial database, while MySQL is an open source database.
- The database functions are different: Dameng database has a good performance in data security, high availability, performance optimization, etc., while MySQL has an excellent performance in large-scale data processing and high concurrent access.
- Different database syntax: Dameng database and MySQL have some differences in SQL syntax, such as data types, functions, stored procedures, etc.
- Different database application scenarios: Dameng database is mainly used in finance, telecommunications, government and other fields, while MySQL is widely used in web applications, enterprise applications and other fields.
It should be noted that although there are some differences between Dameng database and MySQL, they are both mature database management systems, which can be selected and used according to specific needs.
Let’s not gossip, let’s start the steps of mysql data migration to Dameng database (other database data migration can be used as a reference):
1. useDM管理工具
After the Dameng database is installed, a shortcut to the tool will be created in the path shown in the figure below, and it will be found and opened DM管理工具
.
2. Create the corresponding mode in the server connection that needs to be migrated
In Dameng database, a user corresponds to a schema, which is similar to the database in mysql.
You can also create a new user, which is used as a mode for testing migration. If you create a new user, the mode bound to it will be automatically created. Here I have created TEST, so I will not create it again.
3. useDM数据迁移工具
4. Create a migration project
4.1 Right click on the blank space on the left to create a new project, fill in the information and the project is created.
4.2 Create a migration and fill in the migration information
5. Data Migration
5.1 Click the migration item created on the left, and click Next
5.2 Select the migration method
Here we are migrating mysql to Dameng database, so choose mysql here.
5.3 Configure data source
Fill in the data source information, and then click Refresh to display all the databases connected. Select the database to be migrated and click Next, but here I click Refresh to report an error. The following is the solution.
When I click refresh, it prompts that the database connection failed, Communications link failure.
There are several possible reasons for this problem:
1. The port is not open.
Windows netstat -aon|findstr "端口号"
checks whether it is open. If there is no output information, it means that it is not open. Generally speaking, you will not encounter the problem of not being open. I will not repeat it here.
2. SSL protocol problem
The solution steps are as follows:
2.1 Stop Dameng database-related services.
2.2 Find dm.ini in the installation directory of Dameng database. The path I installed on the D disk is here D:\dmdbms\data\DAMENG\dm.ini
. After opening, update COMPATIBLE_MODE
the property and change it to 4 to be compatible with the MYSQL database. After finishing writing, restart the service.
2.3 Custom connection driver
The driver path can be selected from the local driver jar package, check Use custom URL, the URL needs to be added at the end with &useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true, and the database name needs to be changed to the name of the database to be migrated.
Click OK and then click Refresh Test, if no error is reported, go to the next step.
5.4 Configure Dameng database information, migration strategy, and specify which mode to migrate to
5.5 Data Migration
Unselect all the tables, click Next, click Finish after reviewing, confirm that there is no error in the log, and the migration is complete. If there is no accident, I have an accident, and the log prompts a null pointer exception.
Solution:
You can re-enter the migration project by splitting the synchronization, and click Next until the page for selecting the migration object.
- Synchronize table structure.
- Synchronous Data.
Note: If there is a view table here, it needs to be unchecked.
- Synchronize constraints, indexes, triggers, etc.
At this point, the mysql data migration to Dameng Data has been completed, and in the sixth step, the problems encountered in the follow-up will be supplemented.
6. Other issues
6.1 Duplication of index names:
When using Dameng database, if two or more indexes are created and use the same name, Dameng database will report an error and refuse to create the second index. This is because index names must be unique in order to refer to them correctly in queries.
When encountering this kind of problem, you need to change the index name. If there are few indexes, you can change it manually. If there are many indexes, you can use the following sql. The statement given by this sql can update the index names in the database in batches. Generate an index
name in the format of table name + field name :
-- 批量更新索引名的sql
-- 查询出所有组合索引,并拼接修改索引名的语句
SELECT
CONCAT( 'ALTER TABLE `', table_name, '` RENAME INDEX `', index_name, '` TO `', table_name, '_', GROUP_CONCAT( column_name ORDER BY seq_in_index SEPARATOR '_' ), '`;' ) AS RENAME_SQL
FROM
information_schema.statistics
WHERE
table_schema = 'asset_manage_local'
AND index_name != 'PRIMARY'
GROUP BY
table_name,
index_name
HAVING
COUNT(*) > 1 -- 只处理组合索引
UNION ALL
-- 查询出所有非组合索引,并拼接修改索引名的语句
SELECT
CONCAT(
'ALTER TABLE `',
table_name,
'` RENAME INDEX `',
index_name,
'` TO `',
table_name,
'_',
column_name,
IF
( sub_part IS NOT NULL, CONCAT( '(', sub_part, ')' ), '' ),
'`;'
) AS RENAME_SQL
FROM
information_schema.statistics
WHERE
table_schema = 'asset_manage_local'
AND index_name != 'PRIMARY'
AND seq_in_index = 1
AND index_name NOT IN ( SELECT index_name FROM information_schema.statistics WHERE table_schema = 'asset_manage_local' GROUP BY table_name, index_name HAVING COUNT(*) > 1 -- 过滤掉组合索引
);