Mysql verification program after importing data
Refer to the data verification after mysql imports the sample database employees. You can use md5 or sha.
Principle and idea: First, generate each row and column of data in each table in the database to be backed up. The md5 value is calculated cumulatively, and then hardcoded in the test unit file as the expected value.
The following is the verification method of md5
USE employees; SELECT 'TESTING INSTALLATION' as 'INFO'; SET storage_engine=MyISAM; DROP TABLE IF EXISTS expected_values, found_values; CREATE TABLE expected_values ( table_name varchar(30) not null primary key, recs int not null, crc_sha varchar(100) not null, crc_md5 varchar(100) not null ) ENGINE=MyISAM; CREATE TABLE found_values LIKE expected_values; INSERT INTO `expected_values` VALUES ('employees', 300024,'4d4aa689914d8fd41db7e45c2168e7dcb9697359', '4ec56ab5ba37218d187cf6ab09ce1aa1'), ('departments', 9,'4b315afa0e35ca6649df897b958345bcb3d2b764', 'd1af5e170d2d1591d776d5638d71fc5f'), ('dept_manager', 24,'9687a7d6f93ca8847388a42a6d8d93982a841c6c', '8720e2f0853ac9096b689c14664f847e'), ('dept_emp', 331603, 'd95ab9fe07df0865f592574b3b33b9c741d9fd1b', # 'f16f6ce609d032d6b1b34748421e9195c5083da8', Bug#320513 'ccf6fe516f990bdaa49713fc478701b7'), # 'c2c4fc7f0506e50959a6c67ad55cac31'), ('titles', 443308,'d12d5f746b88f07e69b9e36675b6067abb01b60e', 'bfa016c472df68e70a03facafa1bc0a8'), ('salaries', 2844047,'b5a1785c27d75e33a4173aaa22ccf41ebd7d4a9f', 'fd220654e95aea1b169624ffe3fca934'); SELECT table_name, recs AS expected_records, crc_md5 AS expected_crc FROM expected_values; DROP TABLE IF EXISTS tchecksum; CREATE TABLE tchecksum (chk char(100)) ENGINE=myisam; SET @crc= ''; INSERT INTO tchecksum SELECT @crc := MD5(CONCAT_WS('#',@crc, emp_no,birth_date,first_name,last_name,gender,hire_date)) FROM employees ORDER BY emp_no; INSERT INTO found_values VALUES ('employees', (SELECT COUNT(*) FROM employees), @crc,@crc); TRUNCATE tchecksum; -- if BlackHole is not available SET @crc = ''; INSERT INTO tchecksum SELECT @crc := MD5(CONCAT_WS('#',@crc, dept_no,dept_name)) FROM departments ORDER BY dept_no; INSERT INTO found_values values ('departments', (SELECT COUNT(*) FROM departments), @crc,@crc); TRUNCATE tchecksum; SET @crc = ''; INSERT INTO tchecksum SELECT @crc := MD5(CONCAT_WS('#',@crc, dept_no,emp_no, from_date,to_date)) FROM dept_manager ORDER BY dept_no,emp_no; INSERT INTO found_values values ('dept_manager', (SELECT COUNT(*) FROM dept_manager), @crc,@crc); TRUNCATE tchecksum; SET @crc = ''; INSERT INTO tchecksum SELECT @crc := MD5(CONCAT_WS('#',@crc, dept_no,emp_no, from_date,to_date)) FROM dept_emp ORDER BY dept_no,emp_no; INSERT INTO found_values values ('dept_emp', (SELECT COUNT(*) FROM dept_emp), @crc,@crc); TRUNCATE tchecksum; SET @crc = ''; INSERT INTO tchecksum SELECT @crc := MD5(CONCAT_WS('#',@crc, emp_no, title, from_date,to_date)) FROM titles order by emp_no,title,from_date; INSERT INTO found_values values ('titles', (SELECT COUNT(*) FROM titles), @crc,@crc); TRUNCATE tchecksum; SET @crc = ''; INSERT INTO tchecksum SELECT @crc := MD5(CONCAT_WS('#',@crc, emp_no, salary, from_date,to_date)) FROM salaries order by emp_no,from_date,to_date; INSERT INTO found_values values ('salaries', (SELECT COUNT(*) FROM salaries), @crc,@crc); DROP TABLE tchecksum; SELECT table_name, recs as 'found_records ', crc_md5 as found_crc from found_values; SELECT e.table_name, IF(e.recs=f.recs,'OK', 'not ok') AS records_match, IF(e.crc_md5=f.crc_md5,'ok','not ok') AS crc_match from expected_values e INNER JOIN found_values f USING (table_name); DROP TABLE expected_values,found_values;
The above is the content of the verification program after mysql imports data. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.
