Let MySQL support transaction processing

xiaoxiao2021-03-06  91

First, install under Linux

1. Download the stable maximum function version on the MySQL website (current version 3.23.47-max)

2. Note that you can download the binary version, not to compile; don't download the RPM version

3. We will install mysql server to / usr / local, so CD / USR / LOCAL

5. Unope the download profile TAR ZXVF / ROOT/Mysql-max-3.23.47-pc-linux-gnu-i686.tar.gz. /

6. Have time you can look at Install-Binary, or follow the steps below

7.

Shell> GroupAdd MySQL

Shell> UserAdd -g mysql mysql

Shell> CD / USR / LOCAL

Shell> Gunzip

Shell> ln -s mysql-version-os mysql

Shell> cd mysql

Shell> scripts / mysql_install_db

Shell> chown -r root / usr / local / mysql

Shell> Chown -R mysql / usr / local / mysql / data

Shell> chgrp -r mysql / usr / local / mysql

Shell> Chown -R root / usr / local / mysql / bin

Shell> VI StartMysqld

The above command is to edit a startup script, the content is as follows, don't include dotted lines!

# --- Don't do this ----------------------------------------- -------------------------

#! / bin / sh

CD / usr / local / mysql

./bin/safe_mysqld --user = mysql &

CD -

# --- Don't do this ----------------------------------------- ----------------------------

Shell> Chmod 775 StartMysqld

Shell> vi /etc/rc.d/rc.local

The above command is ready to add the launch mySQL command to the system boot file so that the machine is started, and MySQL Server will start, add: / usr / local / mysql / bin / startmysqld, close the VI exit in the last line of the file: / usr / local / mysql / bin / startmysqld.

Shell> StartMysqd

At this time, the following message will appear. If there is no error, continue 8, otherwise check the steps above

Starting mysqld daemon with databases from /usr/local/mysql-max-3.23.47-pc-linux-gnu-i686/data

8. Shell> mysqladmin -uroot shutdown

9. Shell> CD / USR / local / mysql

Shell> CP Support-files / my-small.cnf data / my.cnf

Shell> vi data / my.cnf

Here, open the InnoDB switch and remove those # below.

InnoDB_Data_Home_Dir = / usr / local / mysql / var /

InnoDB_Data_file_path = ibdata1: 100m

InnoDB_Data_Home_Dir = / usr / local / mysql / var /

INNODB_LOG_GROUP_HOME_DIR = / usr / local / mysql / var / innoDB_log_arch_dir = / usr / local / mysql / var /

Set-variable = INNODB_MIRRORED_LOG_GROUPS = 1

Set-variable = INNODB_LOG_FILES_IN_GROUP = 3

Set-variable = INNODB_LOG_FILE_SIZE = 5M

Set-variable = INNODB_LOG_BUFFER_SIZE = 8M

InnoDB_Flush_Log_AT_TRX_COMMIT = 1

InnoDB_log_archive = 0

Set-variable = INNODB_BUFFER_POOL_SIZE = 16M

Set-variable = innodb_additional_mem_pool_size = 2m

Set-variable = innodb_file_io_threads = 4

Set-variable = INNODB_LOCK_WAIT_TIMEOUT = 50

The above configuration saves the INNODB data, logs and other files. Under / usr / local / mysql / var, then create this directory.

10. Shell> mkdir var

Shell> chown mysql.mysql var

Shell> CHMOD G W VAR

Note To make the changedate MySQL user can write, INNODB will not automatically create a directory

11. Shell> StartMysqld

Shell> mysql -uroot

I hope you can see:

Mysql> show variables like "have_%";

------------------ --------

| Variable_name | Value |

------------------ --------

| Have_BDB | Yes |

| Have_gemini | No |

| Have_innodb | Yes |

| Have_Isam | Yes |

| Have_Raid | NO |

| Have_openssl | NO |

------------------ --------

6 ROWS IN Set (0.00 sec)

If this is the case, then we can create a table that supports transaction processing.

1.Mysqladmin -uroot Creat InnoDB creates a database

2. Mysql InnoDB enters MySQL Client

Mysql> Create Table Customer (A INT, B CHAR (20), Index (a)) Type = InnoDB;

Query OK, 0 ROWS Affected (0.02 sec)

Mysql> set autommit = 0;

Query OK, 0 ROWS Affected (0.00 SEC)

MySQL> Insert Into Customer Values ​​(0, "Rainman");

Query Ok, 1 Row Affected (0.00 sec)

mysql> commit;

Query OK, 0 ROWS Affected (0.02 sec)

mysql> Select * from customer;

---- ---------

| A | b |

---- --------- | 0 | Rainman |

---- ---------

1 row in set (0.01 sec)

Mysql> Insert INTO Customer Values ​​(1, "Rainman2");

Query Ok, 1 Row Affected (0.00 sec)

mysql> Select * from customer;

---- ----------

| A | b |

---- ----------

| 0 | RAINMAN |

| 1 | Rainman2 |

---- ----------

2 rows in set (0.00 sec)

mysql> rollback;

Query OK, 0 ROWS Affected (0.02 sec)

mysql> Select * from customer;

---- ---------

| A | b |

---- ---------

| 0 | RAINMAN |

---- ---------

1 row in set (0.00 sec)

mysql> commit;

转载请注明原文地址:https://www.9cbs.com/read-107623.html

New Post(0)