What should I do if there are too many MySQL data fragments?
Solution to too many mysql data fragments: 1. Enter the phpMyAdmin page, click on the MySQL database to be managed in the left column, and there is a column named "Redundant" on the far right of the database; 2. Click on the data table list Click "Only select redundant" below, then click the drop-down menu at the back, and click "Optimize Table" to optimize and clear fragments.
The operating environment of this article: Windows7 system, Dell G3 computer, discuz7.1&&WordPress5.4.2.
Frequent reading and writing of the website database will form a large number of fragments, seriously affecting the reading and writing speed, and also affecting the website access experience. Therefore, it is necessary to regularly optimize data tables and clean up database fragments.
Most websites use the MySQL database. Different website programs have different methods of optimizing and defragmenting the MySQL database.
The following takes the Discuz! website and the WordPress website as examples to introduce in detail the methods and steps for defragmenting the MySQL database.
At the same time, two methods of optimizing the database are also used to verify each other to see the final effect of defragmentation.
How to optimize and defragment the Discuz! website MySQL database
If you use It is a website created by Discuz!. Checking whether the database is fragmented, as well as optimizing and defragmenting the database can be performed in the Discuz! management background. This is also one of the advantages of the Discuz! program being easy to use.
The way to view and optimize the MySQL database fragments of the Discuz! website is to log in to the website management backend using the website founder (webmaster) account, click on the top menu "Webmaster" - "Database" on the left column - " Optimization", as shown below:
As you can see from the above picture, this Discuz! website has a lot of fragmented data tables. The bottom shows that the size of the fragmented data table is 96.37 M.
It is also very convenient to optimize and organize the database fragments of the Discuz! website. Just keep the default status of all data tables to be optimized checked, and click the optimization "Submit" button at the bottom to complete the website Optimize and defragment the MySQL database to remove fragments.
How to optimize and defragment the MySQL database of WordPress websites
WordPress websites also use MySQL database, unlike Discuz!, cannot view and optimize database fragments directly in the WordPress backend.
There are two ways to check the database fragmentation of WordPress website:
First install the MySQL database management plug-in
This method is not recommended. Because the risk of using plug-ins is very high, especially for something as important as managing the database. Once something goes wrong, the website will be destroyed, so you must be cautious.
Then log in to the cPanel host control panel and use the phpMyAdmin management page
Log in to the cPanel host management panel page of the WordPress website, under the "Database" column, click "phpMyAdmin" MySQL database management program, as shown below:
After entering the phpMyAdmin page, click on the MySQL database of the website you want to manage in the left column. There is a column named "Excessive" on the far right side of the database. ”, as shown below:
#What does the “redundant” MySQL database table displayed on the phpMyAdmin management page mean? How was it formed?
Due to the continuous reading and writing process of the database, data is constantly being written and data is constantly being deleted. When data is deleted, it is impossible for all subsequent data records to be moved forward, which causes This is "excess" data. In layman's terms, These "excess" are "fragments" of the database, because they cause data incoherence, which of course affects the reading and writing speed of the database.
Therefore, optimizing these data tables with "redundant" data is to defragment the database.
The method to optimize and clean up the "redundant" fragments in these MySQL databases is: Click "Select only redundant" under the data table list, then click the drop-down menu behind, and click "Optimize Table" ", you can optimize and clear these "excess" fragments, as shown below:
The prompt "Your SQL statement has been successfully run" indicates that the optimization is successful. At this time, you can see that the "extra" column in the MySQL data table is already blank and has no fragments.
Verification of the effect of defragmenting MySQL database
In order to verify whether the "excess" in the MySQL database table in the phpMyAdmin page is fragmented; perform the "Optimize Table" operation to see if these fragments can be removed. Perform the "Optimize Table" and clean up " When there is "redundant" data, the database actually selected is a Discuz! website. Of course, optimizing the WordPress website database also follows the same steps.
After performing the "optimization table" operation on the MySQL database of the Discuz! website on the phpMyAdmin page, now log in to the Discuz! website management background to view the optimization effect.
Enter "Webmaster" - "Database" - "Optimization", you will see that the list of data tables to be optimized is empty, and there is also a prompt below that "the data table is not fragmented and does not need to be optimized", as shown below:
Through mutual verification in this way, it can be seen that the "redundant" MySQL data table in the phpMyAdmin page is indeed a database "fragment". Moreover, after selecting redundant data tables, performing the "Optimize Table" operation can also effectively clean up the fragments of the MySQL database.
In order to keep the website running in good condition, the MySQL database of the website should be defragmented regularly.
The above is the detailed content of What should I do if there are too many MySQL data fragments?. For more information, please follow other related articles on the PHP Chinese website!

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

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

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.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting
