1.安装gcc-c++ gcc make cmake编译器
2.安装ncurses
3.添加用户组
groupadd mysql useradd -r -g mysql mysql
4.安装
tar -zxvf mysql-5.5.12.tar.gz cd mysql-5.5.12 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 make make install
5.配置
cp support-files/my-medium.cnf /etc/my.cnf #如果你的机器的内存教大,可以复制Myhuge.cnf文件 chmod 755 scripts/mysql_install_db scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/ ##初始化数据库 cp support-files/mysql.server /etc/init.d/mysql #设置开机启动mysql chmod 755 /etc/init.d/mysql chkconfig mysql on #开机启动 echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile #将mysql的安装路径加入PATH中,方便启动mysql(重启生效) /etc/init.d/mysql start #启动mysql
6.可以在进程中查看mysql是否启动
ps -le | grep mysqld
netstat -tunpl | grep :3306
7.设置mysql 密码
/usr/local/mysql/bin/mysql -u root SET PASSWORD FOR ‘root‘@‘localhost‘=PASSWORD(‘123456‘);
参考文档:http://blog.csdn.net/westmaniac/article/details/6535000
http://www.linuxidc.com/Linux/2011-12/49046.htm