在RedHat 7.2 下已經驗證
一、在Linux 6.2下安裝
1.在MySQL網站上下載穩定最大功能版本 (當前版本為 3.23.47-max)
2.注意你可以下載二進制版本沒,而不需要編譯;不必下載RPM版本
3.我們將安裝mySQL Server到/usr/local下,故cd /usr/local
5.解開下載檔案 tar zxvf /root/MySQL-max-3.23.47-pc-Linux-gnu-i686.tar.gz ./
6.有空你可以看看 INSTALL-BINARY,或直接按下面的步驟操作
7.
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 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
上面這個命令是要編輯一個啟動腳本,內容如下,不要包括虛線哦!
#---不要這一行--------------------------------------------------------------------
#!/bin/sh
cd /usr/local/MySQL
./bin/safe_mysqld --user=MySQL &
cd -
#---不要這一行---------------------------------------------------------------------
shell> chmod 775 startMySQLd
shell> vi /etc/rc.d/rc.local
上面這個命令是准備把啟動MySQL命令加入系統啟動文件中,這樣機器一啟動完,mySQL Server也就啟動了,在文件的最後一行加入:/usr/local/mysql/bin/startMySQLd,關閉vi退出。
shell>startmysqd
這時出現下面的消息,如果沒有報錯就繼續8,否則檢查上面的步驟
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
這裡把innodb開關打開,去掉那些#象下面一樣。
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_fi
le_io_threads=4
您正在看的MySQL教程是:讓MySQL支持事務處理。sp;CUSTOMER (A INT, B CHAR (20), INDEX (A)) TYPE = InnoDB;
Query OK, 0 rows affected (0.02 sec)
MySQL> set autocommit=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;
行了!