安装所需的编译工具
apt-get install autoconf automake autotools-dev cpp curl gawk gcc lftp libc6-dev linux-libc-dev make libpcre3-dev libpcrecpp0 g++ libtool libncurses5-dev aptitude python python-dev
aptitude install libmysql++-dev libmysqlclient15-dev checkinstall
1 , 安装所需要系统库相关库文件
yum –y install gcc gcc- c++ gcc- g77 autoconf automake zlib* fiex* libxml*
ncurses- devel libmcrypt* libtool- ltdl- devel*
2 , 创建mysql安装目录
# mkdir -p /usr/local/webserver/mysql/
3 , 创建数据存放目录
# mkdir -p /data/mysql/
4 , 创建用户和用户组与赋予数据存放目录权限
# groupadd mysql
# useradd -g mysql mysql
# chown mysql.mysql -R /data/mysql/
5 , 安装cmake(mysql5.5以后是通过cmake来编译的)
# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#.configure
# make && make install
6 , 下载解压mysql 5.5.11
wget http: //mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.11.tar.gz
[ root@localhost down] # tar zxvf mysql-5.5.11.tar.gz
[ root@localhost down] # cd mysql-5.5.11
7 , 编译mysql- 5.5.11
cmake . - DCMAKE_INSTALL_PREFIX=/ usr/ local/ webserver/ mysql/
\- DMYSQL_DATADIR=/ data/ mysql
\- DMYSQL_UNIX_ADDR=/ data/ mysql/ mysqld.sock
\- DWITH_INNOBASE_STORAGE_ENGINE= 1
\- DENABLED_LOCAL_INFILE= 1 \- DMYSQL_TCP_PORT= 3306
\- DEXTRA_CHARSETS= all \- DDEFAULT_CHARSET= utf8
\- DDEFAULT_COLLATION= utf8- general_ci
\- DMYSQL_UNIX_ADDR=/ data/ mysql/ mysql.sock
\- DMYSQL_USER= mysql \- DWITH_DEBUG= 0
[ root@host mysql- 5.5.11] # make
[ root@host mysql- 5.5.11] # make install
8 , 复制配置文件
[ root@mysql- 5.5.11] # cp support-files/my-medium.cnf /etc/my.cnf
[ root@mysql- 5.5.11] # cp support-files/mysql.server /etc/init.d/mysqld
[ root@mysql- 5.5.11] # chmod 755 /etc/init.d/mysqld
9 , 初始化数据库
bash scripts/ mysql_install_db -- user= mysql -- basedir=
/ usr/ local/ webserver/ mysql -- datadir=/ data/ mysql/
10 , 启动mysql服务
[ root@localhost mysql- 5.5.11] # /etc/init.d/mysqld start
11 , 启动完成之后用ps - ef | grep mysql 命令查看是否启动
12 , / usr/ local/ webserver/ mysql/ bin/ mysql - u root - p
通过命令行登录管理MySQL服务器 初始密码为空
13 , 修改root密码
mysql>; use mysql ;
mysql>; update user set password= PASSWORD( "123456" ) where user= 'root' ;
mysql>; FLUSH PRIVILEGES;