yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* //安装编译环境gcc
rz上传cmake-2.8.8.tar.gz和mysql-5.5.32.tar.gz
tar xf cmake-2.8.8.tar.gz //解压make
cd cmake-2.8.8 //进入cmake目录
./configure //编译cmake
gmake //安装gmake
gmake install //安装gmake
cd .. //退出cmake目录
groupadd mysql //创建组
useradd mysql -s /sbin/nologin -M -g mysql //创建用户属于mysql组
tar xf mysql-5.5.32.tar.gz //解压mysql
cd mysql-5.5.32 //进入mysql目录
输入以下内容并回车
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
make && make install //安装mysql
ln -s /application/mysql-5.5.32/ /application/mysql //创建软连接
cd .. //退出mysql目录
cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile //编辑环境变量
source /etc/profile //即时生效
chown -R mysql.mysq /application/mysql/data/ //用户赋权
chmod -R 1777 /tmp/ //文件夹赋权
cd /application/mysql/scripts/ //进入初始化目录
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql //初始化mysql
cd .. //退出
cd /home/oldboy/tools/mysql-5.5.32 //进入目录
cp support-files/mysql.server /etc/init.d/mysqld //创建开机自启动文件
chmod +x /etc/init.d/mysqld //文件夹赋权
/etc/init.d/mysqld start //启动mysql服务
mysql //进入mysql
select user,host from mysql.user; //查看是否有空用户
delete from mysql.user where user=‘‘; //删除空用户
delete from mysql.user where host=‘::1‘; //删除::1
quit //退出mysql
/application/mysql//bin/mysqladmin -u root password ‘oldboy123‘ //添加密码
chkconfig mysqld on //设置开机启动
mysql -uroot -poldboy123 //测试是否可以进入,密码是否正确
本文出自 “11104762” 博客,请务必保留此出处http://11114762.blog.51cto.com/11104762/1812556
原文地址:http://11114762.blog.51cto.com/11104762/1812556