centos6.3下安装mysql 5.5.27

mysql 安装目录 /usr/mysql

安装 gcc gcc-c++
[root@localhost ~]# yum install gcc
[root@localhost ~]# yum install gcc-c++

安装cmake
[root@localhost ~]# cd /software/
[root@localhost software]# tar zxvf cmake-2.8.9.tar.gz 
[root@localhost software]# cd cmake-2.8.9 

[root@localhost cmake-2.8.9]# ./bootstrap
[root@localhost cmake-2.8.9]# gmake
[root@localhost cmake-2.8.9]# gmake install

创建mysql组和用户
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
[root@localhost cmake-2.8.9]# cd /software/
[root@localhost software]# tar zxvf mysql-5.5.27.tar.gz

[root@localhost software]# cd mysql-5.5.27
[root@localhost mysql-5.5.27]# cmake .
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE)


-- Configuring incomplete, errors occurred!
[root@localhost mysql-5.5.27]# rm CMakeCache.txt
[root@localhost mysql-5.5.27]# yum install ncurses-devel
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /software/mysql-5.5.27
[root@localhost mysql-5.5.27]# yum install bison
[root@localhost mysql-5.5.27]# cmake .

[root@localhost mysql-5.5.27]# cd /software/cmake-2.8.9
[root@localhost cmake-2.8.9]# ./configure --prefix=/usr/mysql
[root@localhost cmake-2.8.9]# gmake
[root@localhost cmake-2.8.9]# gmake install
[root@localhost cmake-2.8.9]# cd /software/mysql-5.5.27/
[root@localhost mysql-5.5.27]# cmake -DCMAKE_INSTALL_PREFIX=/usr/mysql \
        -DMYSQL_DATADIR=/usr/mysql/data \
        -DWITH_MYISAM_STORAGE_ENGINE=1 \
        -DWITH_INNOBASE_STORAGE_ENGINE=1 \
        -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
        -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
        -DENABLED_LOCAL_INFILE=1 \
        -DDEFAULT_CHARSET=utf8 \
        -DDEFAULT_COLLATION=utf8_general_ci \
        -DEXTRA_CHARSETS=all \
            -DMYSQL_TCP_PORT=3306 \
[root@localhost mysql-5.5.27]# make && make install

[root@localhost mysql-5.5.27]# cd /usr/mysql/
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .

设置选项文件,将配置文件拷贝到/etc下
[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
启动mysql
[root@localhost mysql]# bin/mysqld_safe --user=mysql &

为root用户设置密码
[root@localhost mysql]# bin/mysqladmin -u root password "root"
[root@localhost mysql]# bin/mysqladmin -u root -h localhost password "root"

以root用户登录mysql
[root@localhost mysql]# bin/mysql -u root

关闭mysql
[root@localhost mysql]# bin/mysqladmin -u root shutdown

方便调用,为mysql设置一个软链接
[root@localhost ~]# ln -s /usr/mysql/bin/mysql /usr/bin/mysql


设置开机自启动
[root@localhost ~]# cd /usr/mysql/
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# chmod +x /etc/init.d/mysql

相关推荐