日期:2014-05-16 浏览次数:20769 次
前置条件:安装cmake工具、gcc工具
gcc一般的linux环境都已经安装,现在安装cmake
[root@localhost workspace]# wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
[root@localhost workspace]# tar xvf cmake-2.8.3.tar.gz
[root@localhost workspace]# cd cmake-2.8.3
[root@localhost workspace]# ./configure
[root@localhost workspace]# make & make install
下载mysql源码包
[root@localhost workspace]# wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.32.tar.gz
[root@localhost workspace]# tar xvf mysql-5.5.32.tar.gz
[root@localhost workspace]# cd mysql-5.5.32
安装第一个MySQL数据库
(1)创建所需要的文件目录
[root@localhost local]# cd /usr/local/
[root@localhost local]# mkdir mysql
[root@localhost local]# cd mysql/
[root@localhost mysql]# mkdir data
[root@localhost mysql]# mkdir etc
(2)配置MySQL源码编译选项
[root@localhost mysql-5.5.32]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DSYSCONFDIR=/usr/local/mysql/etc \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DENABLED_LOCAL_INFILE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DEXTRA_CHARSETS=all \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci
(3)编译安装
[root@localhost mysql-5.5.32]# make & make install
(4)配置第一个MySQL实例
[root@localhost mysql-5.5.32]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql:mysql .
[root@localhost mysql]# cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf
[root@localhost mysql]# vi /usr/local/mysql/etc/my.cnf
添加 datadir=/usr/local/mysql/data
default-storage-engine=MyISAM
[root@localhost mysql]# cd /usr/local/mysql/scripts/
[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
[root@localhost bin]# cd /usr/local/mysql/bin
[root@localhost bin]# ./mysqld_safe --user=root
[1] 28869
[root@localhost bin]# 131016 20:07:13 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
131016 20:07:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data