参考:官方文档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数据库