标签:mysql
上一篇文章介绍了手工编译安装Apache,这篇文章将继续之前的文章,介绍如何编译安装Mysql。-
tar zxvf /opt/lamp/mysql-5.5.24.tar.gz -C /opt/
yum install gcc gcc-c++ make cmake -y
rpm -ivh /mnt/package/ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
rpm -ivh /mnt/package/bison-2.4.1-5.el6.x86_64.rpm
rpm -ivh /mnt/package/libaio-devel-0.3.107-10.el6.x86_64.rpm
useradd -s /sbin/nologin mysql
mkdir -p /usr/local/mysql
4.进入mysql安装目录下
cd /opt/mysql-5.5.24
5.配置文件
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-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
如果报错,清空缓存文件即可
find -name CMakeCache.txt
rm -f ./CMakeCache.txt
chown -R mysql.mysql /usr/local/mysql
vim /etc/profile
在最后一行加入 export PATH=$PATH:/usr/local/mysql/bin/ ; (*开机时刷新*\)
:wq保存
然后重新加载文件运行
source /etc/profile
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add /etc/init.d/mysqld
chkconfig mysqld --level 35 on
将mysqld服务添加进系统服务中,并设置init3、init5中开机自启动
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/home/mysql
service mysqld start
netstat -tnl 3306
mysql>show databases; #注意加分号
标签:mysql
原文地址:http://blog.51cto.com/13620950/2121049