linux下安装mysql

mysql版本:5.5.8
系统版本:Red Hat Enterprise Linux Server release 5.3 (Tikanga)

一、cmake

1、检查是否安装了cmake 

make -i

 2、安装cmake

wget -c http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
tar -zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3
./bootstrap
./configure
make && make install

二、安装mysql

cd..
wget -c http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.8.tar.gz

tar -zxvf mysql-5.5.8.tar.gz

cd mysql-5.5.8/
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_SSL=system -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -LH

make && make install

groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

vim /etc/my.cnf #需要加入basedir,和datadir否则会出问题
[mysqld]
basedir =/usr/local/mysql
datadir =/usr/local/mysql/data

#进入到/usr/local/mysql目录下执行
/usr/local/mysql/scripts/mysql_install_db –user=mysql
chown -R mysql /usr/local/mysql/data
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig –level 345 mysql on
echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
echo “/usr/local/lib” >>/etc/ld.so.conf

ldconfig

/etc/init.d/mysql start

/usr/local/mysql/bin/mysqladmin -u root password 你的MYSQL密码

/etc/init.d/mysql restart
/etc/init.d/mysql stop

你可能感兴趣的:(linux下安装mysql)