centos6.2 mysql5.5.28安装

时间:2022-09-22 15:04:11

安装环境

yum install gcc
yum install gcc-c++
yum install ncurses-devel
yum install bison


建立数据目录

mkdir /var/mysql
mkdir /var/mysql/data

安装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 --prefix=/usr/local/cmake/
make && make install

安装mysql

wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz
tar -zxvf mysql-5.5.28.tar.gz
cd mysql-5.5.28
/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/var/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DSYSCONFDIR=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
make
make install

cd /usr/local/mysql
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
cp support-files/mysql.server /etc/init.d/mysql

vi  /etc/init.d/mysql
conf=/usr/local/mysql/my.cnf # 修改
:wq

chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
groupadd mysql
useradd -g mysql mysql

chmod +w /usr/local/mysql
chmod +w /var/mysql/data

chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /var/mysql/data

/usr/local/mysql/scripts/mysql_install_db --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/var/mysql/data --user=mysql

/usr/local/mysql/bin/mysqld_safe&service mysql start 

修改默认ROOT密码

mysql -uroot
update mysql.user set password=PASSWORD('密码') where User='root';
flush privileges;

修改环境变量

vi /etc/profile
export  PATH=/usr/local/cmake/bin:/usr/local/mysql/bin:$PATH

修改默认8小时连接超时

show variables like '%timeout%'; #查看

vi /usr/local/mysql/my.cnf
interactive_timeout=28800000 #加入[mysqld]后面
wait_timeout=28800000