mysql ¹²ÏíËø ÅÅËûËø ·À²åÈëËø
ÊÔÑé1
ÊÂÎñ1£º
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test")
while str!="1":
str = raw_input()
cursor.execute("update test id=id-1")
while str!="exit":
str = raw_input()
cursor.close()
conn.close()
ÔÚmysqlÃüÁîÐÐÖÐÊäÈëÒÔÏ£º
mysql> select * from test;
µ±ÊÂÎñ1ÖеȴýÊäÈë1ʱ£¬ÏÔʾ³öselectÆ¥ÅäµÄÐÐ
µ±ÊÂÎñ1ÖÐÊäÈë1ʱ£¬ÏÔʾ½á¹ûÈçÏ£º
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
½áÂÛ£ºµ±selectʱ»á¼ì²âµ±Ç°ÊÇ·ñÓÐÊÂÎñ»áÐ޸썱ÈÓ°ÏìҪȷÇÐһЩ£©µ±Ç°µÄ¼Ç¼ʱ£¬²Å»á±»×èÈû¡£
ÊÔÑé2
ÔÚÊÂÎñ1£º
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test lock in share mode")
while str!="exit":
str = raw_input()
cursor.close()
conn.close()
ÔÚmysqlÃüÁîÐÐÖÐÊäÈëÒÔÏ£º
mysql> update test set id=id-1;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
½áÂÛ£ºµ±ÊÂÎñÖаüº¬select ...lock in share modeµÄʱºò£¬Ïà¹Ø¼Ç¼½«»á±»Ëø×¡£¬²»ÔÊÐí½øÐÐÐ޸ġ£
ÊÔÑé3
Ö´ÐÐÏÂÃæµÄpython½Å±¾Á½±é£¬²¢ÇÒͬʱÊäÈë1£¬2Ö®ºó
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test lock in share mode")
str = ""
while str!="1":
str = raw_input()
while str!="2":
str = raw_input()
cursor.execute("update test set id=id-1")
while str!="exit":
str = raw_input()
cursor.close()
conn.close()
[root@TJSJHL196-139 tmp]# python test_transaction.py
1
2
Traceback (most recent call la
Ïà¹ØÎĵµ£º
´ÓAÖ÷»úµ¼ÈëÊý¾Ýµ½BÖ÷»ú
mysqldump -hA -uusername -ppassword db_name >dumpfile
mysql -hB -uusername -ppassword
mysql>create database db_name2;
mysql>use db_name2;
mysql>source dumpfile;
ÏÈÓÃdump°ÑAÖеÄÊý¾Ý¿âdb_nameµ¼Èëµ½Îļþdumpfile£¬È»ºóÔÚBÖ÷»úÉÏ£¬´´½¨Ò»¸öеÄÊý¾Ý¿âdb_name2£¬Ê¹Óà ......
MySQL°²×°Ä¿Â¼ÏµÄDataĿ¼ÖÐ .err´íÎóÐÅÏ¢:
Default storage engine (InnoDB) is not available
½â¾ö°ì·¨:
ɾ³ýÔÚMySQL°²×°Ä¿Â¼ÏµÄDataĿ¼ÖеÄ
ib_logfile0
ib_logfile1
ÖØÐÂÆô¶¯MySQLµÄService ......
1.¼ì²éÒÔǰ°²×°µÄMySQL,Ð¶ÔØ¡£
rpm -qa|grep -i mysql
rpm -e XXXXX
×¢Èç¹û³öÏÖÁ½ÌõÏàͬµÄ£¬ÔòʹÓÃrpm -e --allmatches
2.°²×°rpm°ü¡£
rpm -ivh MySQL-server-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-shared-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-community-5.1.37-0.rhel5.x86_6 ......
MySQLÓÐËÄÖÖBLOBÀàÐÍ:
¡¡¡¡·tinyblob:½ö255¸ö×Ö·û
¡¡¡¡·blob:×î´óÏÞÖÆµ½65K×Ö½Ú
¡¡¡¡·mediumblob:ÏÞÖÆµ½16M×Ö½Ú
¡¡¡¡·longblob:¿É´ï4GB
¡¡¡¡ÔÚÿ¸öMySQLµÄÎĵµ(´ÓMySQL4.0¿ªÊ¼)µÄ½éÉÜÖÐ,Ò»¸ölongblobÁеÄ×î´óÔÊÐí³¤¶ÈÒÀÀµÓÚÔÚ¿Í»§/·þÎñÆ÷ÐÒéÖпÉÅäÖõÄ×î´ó°üµÄ´óСºÍ¿ÉÓÃÄÚ´æÊý¡£
¡¡¡ ......