Redhat下MySQL5.5.20安装配置

fmms 13年前

mysql </span>最新的版本都需要</span>cmake</span>编译安装,估计以后的版本也会采用这种方式,所以特地记录一下安装步骤及过程,以供参考。</span>
注意:此安装是默认</span>Redhat</span>下已经安装了最新工具包,比如</span>GNU make, GCC, Perl, libncurses5-dev</span>,如果在编译安装过程中发现有缺失的工具包,先</span>yum install </span>单独下载安装再继续即可。</span>

</span>. linux</span></span> wget </span>下载需要的软件,保存到目录</span> /usr/local/src </span></span>
</span>

wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.20.tar.gz

wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
</span></span>

wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz


安装 cmake
cd /usr/local/src
tar zxvf cmake-2.8.7.tar.gz
cd cmake-2.8.7.tar.gz
./bootstrap
gmake
gmake install
cd ../

tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure
make
make install
cd ../

编译安装 MySQL 5.5.20
groupadd –g 1000 mysql
useradd –u 1000 –g mysql mysql
tar xvf mysql-5.5.20.tar.gz
cd mysql-5.5.20/
/usr/local/bin/cmake .

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 
-DMYSQL_UNIX_ADDR=/tmp/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_DEBUG=0 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/mysql/data \
-DMYSQL_USER=mysql

-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found.  Pleaseinstall appropriate package,
removeCMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:117 (FIND_CURSES)
cmake/readline.cmake:213(MYSQL_USE_BUNDLED_READLINE)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE)

yum install ncurses-devel
rm CMakeCache.txt
-- 
这里重新开始做cmake操作即可
make
make install
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18
mkdir -p /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql/data
ln -s /usr/local/mysql/data /home/mysql/data
mkdir -p /var/mysql/log/
chown -R mysql:mysql /var/mysql/
cd support-files/
cp my-large.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld

配置启动MySQL 5.5.20
1. 
若有需要请先修改 mysql 的配置 my.cnf
vi /etc/my.cnf
     

[mysqld] 下添加
basedir = /usr/local/mysql    
datadir = /usr/local/mysql/data

2.my.cnfmysql 初始化安装
/usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data \
--user=mysql

3. 
 mysql 加入开机启动
chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld 
(编辑此文件,查找并修改以下变量内容:)
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
chkconfig --add mysqld
chkconfig --level 345 mysqld on

4. 
启动 mysql
service mysqld start

5. 
配置访问帐号taxioncall

/usr/local/mysql/bin/mysqladmin -uroot password zdsoft
/usr/local/mysql/bin/mysql -uroot -p
mysql>use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO taxioncall@'%' IDENTIFIED BY 'zdsoft' with GRANT OPTION;

mysql>update user set password=password('zdsoft');  --所有用户都密码更新

mysql>FLUSH   PRIVILEGES;
mysql>quit;


转自:http://blog.csdn.net/xujinyang/article/details/7261229