免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1234 | 回复: 0
打印 上一主题 下一主题

支持事务处理的mysql的安装,测试入门 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-03-23 14:42 |只看该作者 |倒序浏览

  1. 让mysql支持事务

  2. 1.下载二进制版本没,而不需要编译
  3. 下载地址 http://dev.mysql.com/get/Downloads/MySQL-4.0/mysql-standard-4.0.24-pc-linux-gnu-i686.tar.gz/from/http://mysql.ihostunit.com/

  4. 2. 安装mysql
  5.      shell>; groupadd mysql
  6.      shell>; useradd -g mysql mysql
  7.      shell>; cd /usr/local
  8.      shell>; gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
  9.      shell>; ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
  10.      shell>; cd mysql
  11.      shell>; scripts/mysql_install_db --user=mysql
  12.      shell>; chown -R root  .
  13.      shell>; chown -R mysql data
  14.      shell>; chgrp -R mysql .
  15.      shell>; bin/mysqld_safe --user=mysql &

  16. 3.使用mysql随系统自动启动
  17. shell>; echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >;>; /etc/rc.local

  18. 4.查看inodb信息
  19.      shell>; /usr/local/mysql -u root -p
  20.      mysql>; show variables like "have_%"
  21. 系统会提示:
  22. +------------------+-------+
  23. | Variable_name    | Value |
  24. +------------------+-------+
  25. | have_bdb         | YES   |
  26. | have_crypt       | YES   |
  27. | have_innodb      | YES   |
  28. | have_isam        | YES   |
  29. | have_raid        | YES   |
  30. | have_symlink     | YES   |
  31. | have_openssl     | NO    |
  32. | have_query_cache | YES   |
  33. +------------------+-------+
  34. 8 rows in set (0.05 sec)
  35. 如果是这样的,那么我们就可以创建一张支持事务处理的表来试试了。

  36. 5.测试mysql的事务处理
  37.   mysql>; use test;
  38.   #创建一个支持事务处理的数据表
  39.   mysql>; CREATE TABLE student (id INT, name CHAR (20), index (id)) TYPE = InnoDB;
  40.   #正常插入
  41.   mysql>; INSERT INTO student VALUES(1,"Jack");
  42.   mysql>; select * from student;
  43. +------+------+
  44. | id   | name |
  45. +------+------+
  46. |    1 | Jack |
  47. +------+------+
  48. 1 row in set (0.01 sec)
  49. #开始事务处理
  50. mysql>; set autocommit=0;
  51. mysql>; INSERT INTO student VALUES(2,"wind");
  52. mysql>; insert into student values(3,"liu");
  53. #提交一个事务
  54. mysql>; COMMIT;


  55. mysql>; select * from student;
  56. +------+------+
  57. | id   | name |
  58. +------+------+
  59. |    1 | Jack |
  60. |    2 | wind |
  61. |    3 | liu  |
  62. +------+------+
  63. 3 rows in set (0.00 sec)


  64. #测试事务回滚操作
  65. msyql>;insert into student values(4,"liu");

  66. mysql>; select * from student;
  67. +------+------+
  68. | id   | name |
  69. +------+------+
  70. |    1 | Jack |
  71. |    2 | wind |
  72. |    3 | liu  |
  73. |    4 | liu  |
  74. +------+------+
  75. 4 rows in set (0.00 sec)
  76. # 事务回滚
  77. mysql>; RollBack;

  78. mysql>; select * from student;
  79. +------+------+
  80. | id   | name |
  81. +------+------+
  82. |    1 | Jack |
  83. |    2 | wind |
  84. |    3 | liu  |
  85. +------+------+
  86. 3 rows in set (0.01 sec)


  87.      
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP