利旧原来安装的XAMPP,但使MySQL支持Transaction

本文介绍如何在XAMPP环境下为MySQL数据库启用InnoDB存储引擎以支持事务处理。通过修改my.cnf配置文件,具体步骤包括取消注释相关设置并调整内存分配参数。

 一直使用Mysql,最近才了解到Mysql支持了Transaction。老了,跟不少潮流了。

那就把原来的应用改成Based On Transaction的吧。

将建表语句改成Engine=InnoDB,好像还是不行,没有想象中那么简单。

查一查,哦,发现XAMPP安装的Mysql还要修改conf文件:

 

XAMPP from Apache Friends is a collection of free open source apps that make it easy to install Apache distribution containing MySQL, PHP and Perl. There are four XAMPP distributions for Windows, Linux , Mac OS X and Solaris. To set up an Apache web server with XAMPP, simply download and extract XAMPP, and the Apache HTTPD web server is ready after one or two more auto-execute scripts. There are no changes to the Windows registry (unless you’re using Widows installer version of XAMPP) and it’s not necessary to edit any configuration files.

However, by default, InnoDB MySQL database storage engine is not enabled in the my.cnf configuration file. If a webmaster plans to use InnoDB features, such as one to many or many to many table relationships on foreign key constraints, or transaction-safe commands such as commit, rollback and crash recovery capabilities.

 

To enable the support of MySQL server on InnoDB storage engine, locate the “my.cnf” config file (normally in /installation_path/xampp/mysql/bin/ directory), and edit the my.cnf with any text editor such as vi.

Search and locate each of the following lines (except the lines in italic where they’re comments):

- Comment the following line to unskip and use InnoDB
skip-innodb

- Uncomment the following options for InnoDB database if you are using InnoDB tables.
#innodb_data_home_dir = C:/xampp/xampp/mysql/data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:/xampp/xampp/mysql/data/
#innodb_log_arch_dir = C:/xampp/xampp/mysql/data/

- Uncomment the lines and set innodb_buffer_pool_size up to 50% – 80% of RAM for optimization of InnoDB databases, try not to memory usage too high.
#set-variable = innodb_buffer_pool_size=16M
#set-variable = innodb_additional_mem_pool_size=2M

- Uncomment the lines and set innodb_log_file_size to 25% of InnoDB buffer pool size for optimisation.
#set-variable = innodb_log_file_size=5M
#set-variable = innodb_log_buffer_size=8M
#innodb_flush_log_at_trx_commit=1
#set-variable = innodb_lock_wait_timeout=50

After modification, the code for each lines should look like this:

# skip-innodb

innodb_data_home_dir = C:/xampp/xampp/mysql/data/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = C:/xampp/xampp/mysql/data/
innodb_log_arch_dir = C:/xampp/xampp/mysql/data/

set-variable = innodb_buffer_pool_size=16M
set-variable = innodb_additional_mem_pool_size=2M

set-variable = innodb_log_file_size=5M
set-variable = innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=1
set-variable = innodb_lock_wait_timeout=50

 

 

OK。测试,通过!

支持事务了,就这么简单!

 

想想,每年Oracle在我们单位要拿那么多的单,动则就是几十万,这次好像还为了价格谈崩了,几个项目都因为Oracle到不了位,项目经理急得头疼。何不换个角度思考一下,把一些不是那么Key的应用换成Mysql的,再找个好一点的厂家来支撑一下,一年怎么也得节省个几百万啊,再加上以后每年的维护费用,瓦塞,那不可以省上千万啊。关键是看领导有没有这个魄力啊!

2025-08-14 7:30:00 0 [Note] Starting MariaDB 10.4.28-MariaDB-log source revision c8f2e9a5c0ac5905f28b050b7df5a9ffd914b7e7 as process 18600 2025-08-14 7:30:01 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created! 2025-08-14 7:30:01 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions 2025-08-14 7:30:01 0 [Note] InnoDB: Uses event mutexes 2025-08-14 7:30:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.12 2025-08-14 7:30:01 0 [Note] InnoDB: Number of pools: 1 2025-08-14 7:30:01 0 [Note] InnoDB: Using SSE2 crc32 instructions 2025-08-14 7:30:01 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M 2025-08-14 7:30:01 0 [Note] InnoDB: Completed initialization of buffer pool 2025-08-14 7:30:01 0 [Note] InnoDB: Setting file 'E:\xampp\mysql\data\ibdata1' size to 10 MB. Physically writing the file full; Please wait ... 2025-08-14 7:30:01 0 [Note] InnoDB: File 'E:\xampp\mysql\data\ibdata1' size is now 10 MB. 2025-08-14 7:30:01 0 [Note] InnoDB: Setting log file E:\xampp\mysql\data\ib_logfile101 size to 5242880 bytes 2025-08-14 7:30:01 0 [Note] InnoDB: Setting log file E:\xampp\mysql\data\ib_logfile1 size to 5242880 bytes 2025-08-14 7:30:01 0 [Note] InnoDB: Renaming log file E:\xampp\mysql\data\ib_logfile101 to E:\xampp\mysql\data\ib_logfile0 2025-08-14 7:30:01 0 [Note] InnoDB: New log files created, LSN=11451 2025-08-14 7:30:01 0 [Note] InnoDB: Doublewrite buffer not found: creating new 2025-08-14 7:30:01 0 [Note] InnoDB: Doublewrite buffer created 2025-08-14 7:30:01 0 [Note] InnoDB: 128 out of 128 rollback segments are active. 2025-08-14 7:30:01 0 [Note] InnoDB: Creating foreign key constraint system tables. 2025-08-14 7:30:01 0 [Note] InnoDB: Creating tablespace and datafile system tables. 2025-08-14 7:30:01 0 [Note] InnoDB: Creating sys_virtual system tables. 2025-08-14 7:30:01 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2025-08-14 7:30:01 0 [Note] InnoDB: Setting file 'E:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2025-08-14 7:30:01 0 [Note] InnoDB: File 'E:\xampp\mysql\data\ibtmp1' size is now 12 MB. 2025-08-14 7:30:01 0 [Note] InnoDB: Waiting for purge to start 2025-08-14 7:30:01 0 [Note] InnoDB: 10.4.28 started; log sequence number 0; transaction id 7 2025-08-14 7:30:01 0 [Note] Plugin 'FEEDBACK' is disabled. 2025-08-14 7:30:01 0 [Note] Zerofilling moved table: '.\mysql\plugin' 2025-08-14 7:30:01 6 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1932: Table 'mysql.gtid_slave_pos' doesn't exist in engine 2025-08-14 7:30:01 0 [Note] Zerofilling moved table: '.\mysql\servers' 2025-08-14 7:30:01 0 [Note] Server socket created on IP: '::'.
08-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值