系统centos
下载
>wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.45.tar.gz创建用户
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
创建数据存储目录
mkdir -p /data/mysql_db
chown -R mysql:mysql /data/mysql_db
安装cmake 用来编译
安装编译器等依赖
>yum -y install gcc gcc-c++ ncurses ncurses-devel
>yum -y install cmake编译安装
>tar zxf mysql-5.5.45.tar.gz
>cd mysql-5.5.45
>cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql_db -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DENABLE_DTRACE=OFF -DMYSQL_TCP_PORT=3306
>make
>make install
复制配置文件
>cd support-files/
>cp my-large.cnf /etc/my.cnf
>cp mysql.server /etc/init.d/mysqld
初始化设置
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql_db --user=mysql
设置开机启动
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
添加mysql shell到PATH
>echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
>source /etc/profile
>echo "/usr/local/mysql/lib">>/etc/ld.so.conf
>ldconfig
启动
>/etc/init.d/mysqld start
配置root用户密码
>mysql
>use mysql;
>update user set password=password('xxxx') where user='root';
>flush privileges;
>quit;
参考
http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html