Home Database Mysql Tutorial 为MySQL数据文件ibdata1瘦身

为MySQL数据文件ibdata1瘦身

Jun 07, 2016 pm 03:20 PM
l mysql data document lose weight Enter

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 MySQL在运行一段时间后,ibdata1的文件会增长大小,就算删除了表的数据,ibdata1的体积也不会减

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  MySQL在运行一段时间后,ibdata1的文件会增长大小,就算删除了表的数据,ibdata1的体积也不会减小。由于硬盘空间有限,这样一直膨胀下去磁盘空间接近崩溃。今天在导出数据的时候就发现了,磁盘竟然满了,明明预留了1个月的用量,1周就占满了,下面就要给ibdata1做个瘦身。

  1. 系统环境

  Linux Ubuntu 13.04 64bit server

  ~ uname -a

  Linux d2 3.8.0-21-generic #32-Ubuntu SMP Tue May 14 22:16:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

  ~ cat /etc/issue

  Ubuntu 13.04 \n \l

  MySQL: 5.5.31-0ubuntu0.13.04.1

  ~ mysql --version

  mysql  Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline 6.2

  硬盘:36G+4G+4G+36G

  ~ df -h

  Filesystem                    Size  Used Avail Use% Mounted on

  /dev/mapper/server3--vg-root   36G   31G  3.2G  91% /

  none                          4.0K     0  4.0K   0% /sys/fs/cgroup

  udev                          4.1G  1.1G  3.0G  26% /dev

  tmpfs                         824M  280K  823M   1% /run

  none                          5.0M     0  5.0M   0% /run/lock

  none                          4.1G  3.4G  729M  83% /run/shm

  none                          100M     0  100M   0% /run/user

  /dev/vda1                     228M   30M  187M  14% /boot

  192.168.1.10:/home/amg/data    36G   13G   21G  39% /home/amg/data

  MySQL的ibdata1占用空间:20G

  ~ cd /var/lib/mysql

  ~ ls -l

  drwxr-xr-x 2 mysql mysql        4096 Aug  2 19:38 CB

  drwxr-xr-x 2 mysql mysql        4096 Jun 24 23:08 conan

  drwxr-xr-x 2 mysql mysql        4096 Jun  2 00:52 dbwordpress

  -rwxr-xr-x 1 root  root            0 May 23 00:48 debian-5.5.flag

  -rwxr-xr-x 1 mysql mysql 20101201920 Aug  2 20:08 ibdata1

  -rwxr-xr-x 1 mysql mysql     5242880 Aug  2 20:08 ib_logfile0

  -rwxr-xr-x 1 mysql mysql     5242880 Aug  2 19:38 ib_logfile1

  drwxr-xr-x 2 mysql mysql        4096 Jun 26 09:03 Macro

  drwxr-xr-x 2 mysql root         4096 May 23 00:48 mysql

  -rwxr-xr-x 1 root  root            6 May 23 00:48 mysql_upgrade_info

  drwxr-xr-x 2 mysql mysql        4096 May 23 00:48 performance_schema

  drwxr-xr-x 2 mysql mysql        4096 May 23 00:53 phpmyadmin

  drwxr-xr-x 2 mysql root         4096 May 23 00:48 test

  drwxr-xr-x 2 mysql mysql        4096 Jul 22 14:09 TF

  drwxr-xr-x 2 mysql mysql        4096 Jun  2 01:04 wordpress

  业务数据表

  mysql> show tables;

  +-----------------+

  | Tables_in_CB    |

  +-----------------+

  | NSpremium       |

  | cb_hft          |

  | cb_hft_20130801 |

  | cb_hft_20130802 |

  +-----------------+

  4 rows in set (0.00 sec)

  2. 发现问题

  ibdata1单个文件占用20G大小。

  1. MySQL默认设置,没有按表空间分离数据,所有的表的数据都被放到ibdata1文件中。

  2. 业务操作,每天会产生一张表cb_hft,晚上的时候对表进行重命名。

  RENAME TABLE cb_hft TO cb_hft_20130801;

  create table cb_hft like cb_hft_20130801;

[1] [2] [3] 

为MySQL数据文件ibdata1瘦身

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI 70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI Jun 13, 2024 pm 03:47 PM

70B model, 1000 tokens can be generated in seconds, which translates into nearly 4000 characters! The researchers fine-tuned Llama3 and introduced an acceleration algorithm. Compared with the native version, the speed is 13 times faster! Not only is it fast, its performance on code rewriting tasks even surpasses GPT-4o. This achievement comes from anysphere, the team behind the popular AI programming artifact Cursor, and OpenAI also participated in the investment. You must know that on Groq, a well-known fast inference acceleration framework, the inference speed of 70BLlama3 is only more than 300 tokens per second. With the speed of Cursor, it can be said that it achieves near-instant complete code file editing. Some people call it a good guy, if you put Curs

AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! Jun 08, 2024 pm 01:00 PM

Last week, amid the internal wave of resignations and external criticism, OpenAI was plagued by internal and external troubles: - The infringement of the widow sister sparked global heated discussions - Employees signing "overlord clauses" were exposed one after another - Netizens listed Ultraman's "seven deadly sins" Rumors refuting: According to leaked information and documents obtained by Vox, OpenAI’s senior leadership, including Altman, was well aware of these equity recovery provisions and signed off on them. In addition, there is a serious and urgent issue facing OpenAI - AI safety. The recent departures of five security-related employees, including two of its most prominent employees, and the dissolution of the "Super Alignment" team have once again put OpenAI's security issues in the spotlight. Fortune magazine reported that OpenA

See all articles