#在线下载安装gcc
yum -y install gcc*
[root@guang01 ~]# tar -zxvf bison-2.5.tar.gz -C /usr/src/
[root@guang01 ~]# cd /usr/src/bison-2.5/
[root@guang01 bison-2.5]# ./configure
[root@guang01 bison-2.5]# make && make install
#在线下载安装
yum -y install bison
[root@guang01 bison-2.5]# cd
[root@guang01 ~]# tar -zxvf cmake-3.7.2.tar.gz -C /usr/src/
[root@guang01 ~]# cd /usr/src/cmake-3.7.2/
[root@guang01 cmake-3.7.2]# ./bootstrap
[root@guang01 cmake-3.7.2]# gmake && gmake install
#在线下载安装
yum -y install cmake
[root@guang01 cmake-2.8.7]# cd
[root@guang01 ~]# tar -zxvf mysql-5.5.22.tar.gz -C /usr/src/
[root@guang01 ~]# cd /usr/src/mysql-5.5.22/
[root@guang01 mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSET=all
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:127 (FIND_CURSES)
cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:268 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!
[root@guang01 mysql-5.5.22]#
删除CMakeCache.txt并安装ncurses-devel之后再次执行操作就可以了
[root@guang01 mysql-5.5.22]# rm -rf CMakeCache.txt
[root@guang01 mysql-5.5.22]# yum -y install ncurses-devel
[root@guang01 mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSET=all
make && make install
[root@guang01 mysql-5.5.22]# useradd -M -s /sbin/nologin mysql
[root@guang01 mysql-5.5.22]# chown -R mysql:mysql /usr/local/mysql/
[root@guang01 mysql-5.5.22]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@guang01 mysql]# mkdir -p /var/mysql/{data,log}
[root@guang01 mysql-5.5.22]# chown -R mysql.mysql /var/mysql/
[root@guang01 mysql-5.5.22]# cd /usr/src/mysql-5.5.22/support-files/
You have mail in /var/spool/mail/root
[root@guang01 support-files]# pwd
/usr/src/mysql-5.5.22/support-files
[root@guang01 support-files]# cp my-large.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@guang01 support-files]# cd
[root@guang01 ~]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/var/mysql/data --user=mysql
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
[root@guang01 ~]# cd /usr/src/mysql-5.5.22/support-files/
[root@guang01 support-files]# cp mysql.server /etc/init.d/mysqld
[root@guang01 support-files]# chmod +x /etc/init.d/mysqld
[root@guang01 support-files]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/var/mysql/data
[root@guang01 support-files]# chkconfig --add mysqld
[root@guang01 support-files]# chkconfig mysqld on
[root@guang01 support-files]# chkconfig --list mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@guang01 support-files]# service mysqld start
Starting MySQL.. [确定]
#CentOS7之后,mysqlld=mysql,注意书写。
[root@guang01 support-files]# mysql -uroot -p
bash: mysql: command not found
[root@guang01 ~]# echo "PATH=$PATH:/usr/local/mysql/bin" > /etc/profile
[root@guang01 ~]# . /etc/profile //有空格
[root@guang01 ~]# mysql -uroot -p
Enter password: //没设置密码,直接回车登陆
\q 或 exit 都可以退出
[root@guang01 ~]# mysqladmin -uroot -p password "123.com" //设置新密码为123.com
Enter password: //输入原密码,为空,直接回车
[root@guang01 ~]# mysql -uroot -p
Enter password: //再次登陆,密码为123.com
完成