參考:官方文檔http://dev.mysql.com/doc/refman/5.1/en/installing.html
這裏主要介紹下面的安裝方式:Installing MySQL from Generic Binaries on Unix/Linux
操作系統版本Linux version 2.6.32-131.0.15.el6.i686
mysql的目錄結構簡介
Directory
Contents of Directory
bin
Client programs and the mysqld server
data
Log files, databases
docs
Manual in Info format
man
Unix manual pages
include
Include (header) files
lib
Libraries
scripts
mysql_install_db
share
Miscellaneous support files, including error messages, sample configuration files, SQL for database installation
sql-bench
Benchmarks
安裝步驟
1、下載(32位)安裝包mysql-5.1.60-linux-i686-glibc23.tar.gz
2、創建用戶和用戶組
shell>groupadd mysql
shell>useradd -r -g mysql mysql
3、解壓安裝包安裝包mysql-5.1.60-linux-i686-glibc23.tar.gz
shell>cd /usr/local
shell>tar zxvf
/path/to/mysql-VERSION-OS
.tar.gz
4、做軟連接
ln -s
full-path-to-mysql-VERSION-OS
mysql
5、修改安裝目錄權限
shell>chown -R mysql:mysql .
6、運行腳本creates the MySQL Server system tables
scripts/mysql_install_db --user=mysql
腳本會根據/usr/local/mysql/share/mysql_system_tables.sql創建系統表,如果不運行的話沒有host表,是不能登陸mysql服務的
7、修改目錄權限
shell>chown -R root .
shell>chown -R mysql data
8、修改配置文件(可選)
# Next command is optional shell>cp support-files/my-medium.cnf /etc/my.cnf
9、運行啓動mysql
shell> bin/mysqld_safe --user=mysql &
10、添加到系統服務中(可以通過service ServiceName start/stop/restart來啓停服務)
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysqld
11、添加開機自啓動
# Next command is optional
shell> chkconfig mysqld on
mysql.server腳本主要通過調用腳本bin/mysqld_safe來啓動mysql數據庫