让mysql支持事务
来源:互联网 发布:软件生存周期阶段 编辑:程序博客网 时间:2024/06/06 07:01
让mysql支持事务
1.下载二进制版本没,而不需要编译
下载地址 http://dev.mysql.com/get/Downloa ... ysql.ihostunit.com/
2. 安装mysql
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
3.使用mysql 随系统自动启动
shell> vi /etc/rc.local
加入下面一行
/usr/local/mysql/bin/mysqld_safe --user=mysql &
4.查看inodb信息
shell> /usr/local/mysql -u root -p
mysql> show variables like "have_%"
系统会提示:
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_bdb | YES |
| have_crypt | YES |
| have_innodb | YES |
| have_isam | YES |
| have_raid | YES |
| have_symlink | YES |
| have_openssl | NO |
| have_query_cache | YES |
+------------------+-------+
8 rows in set (0.05 sec)
如果是这样的,那么我们就可以创建一张支持事务处理的表来试试了。
5.测试 mysql的事务处理
mysql> use test;
#创建一个支持事务处理的数据表
mysql> CREATE TABLE student (id INT, name CHAR (20), index (id)) TYPE = InnoDB;
#正常插入
mysql> INSERT INTO student VALUES(1,"Jack");
mysql> select * from student;
+------+------+
| id | name |
+------+------+
| 1 | Jack |
+------+------+
1 row in set (0.01 sec)
#开始事务处理
mysql> set autocommit=0;
mysql> INSERT INTO student VALUES(2,"wind");
mysql> insert into student values(3,"liu");
#提交一个事务
mysql> COMMIT;
mysql> select * from student;
+------+------+
| id | name |
+------+------+
| 1 | Jack |
| 2 | wind |
| 3 | liu |
+------+------+
3 rows in set (0.00 sec)
#测试事务回滚操作
msyql>insert into student values(4,"liu");
mysql> select * from student;
+------+------+
| id | name |
+------+------+
| 1 | Jack |
| 2 | wind |
| 3 | liu |
| 4 | liu |
+------+------+
4 rows in set (0.00 sec)
# 事务回滚
mysql> RollBack;
mysql> select * from student;
+------+------+
| id | name |
+------+------+
| 1 | Jack |
| 2 | wind |
| 3 | liu |
+------+------+
3 rows in set (0.01 sec)
- 让mysql支持事务
- 让mysql支持事务
- mysql支持事务
- MySql支持事务
- 让Mysql支持事务处理
- 让PHP5支持MYSQL
- 让mysql支持InnoDB
- 让mysql支持中文
- 让mysql支持innodb
- 让mysql支持innodb
- 让MySQL支持中文
- 让mysql支持表情
- 让MySQL支持中文
- 让MySQL支持中文
- 事务的概念和MySQL事务支持
- 事务的概念和MySQL事务支持
- Mysql对事务的支持
- 让你的对象支持事务
- 硬盘MBR
- 实战在Centos5.3下mod_dosevasive对抗DDos攻击
- WPF中ListView展示倒影效果
- Apache2 httpd.conf配置文件中文版详解
- JS验证
- 让mysql支持事务
- linux学习笔记-读《Linux编程技术详解》(12)-Linux 系统下的多线程
- Bundle类加载器:classloader
- 做了表的空间迁移后,索引失效处理
- Struts+Spring+连接池 配置
- ubuntu MySQL导入导出数据库详解
- 更改 hostname
- Oracle 回滚(ROLLBACK)和撤销(UNDO)
- Windows环境下PHP多虚拟机设置、Apache+php+mysql