当前位置:Gxlcms > mysql > centos5.9安装mysql5.5.31_MySQL

centos5.9安装mysql5.5.31_MySQL

时间:2021-07-01 10:21:17 帮助过:6人阅读

CentOS

bitsCN.com

centos 5.9安装mysql 5.5.31

在linux下安装安装mysql,会出现各种各样的依赖关系,在centos下安装mysql出现各种依赖关系

[root@localhost]# tar xzvf cmake-2.8.4.tar.gz

[root@localhost src]# cd cmake-2.8.4

[root@localhost cmake-2.8.4]# ./configure

Error when bootstrapping CMake: Cannot find appropriate C compiler on this system. Please specify one using environment variable CC. See cmake_bootstrap.log for compilers attempted.

报错:缺少C的编译器。

安装gcc编译器

可以从Linux系统的安装盘中安装,也可以简单地用yum安装

[root@localhost ~]# yum install gcc

继续cmake的安装

[root@localhost cmake-2.8.4]# ./configure

C compiler on this system is: cc

Error when bootstrapping CMake: Cannot find appropriate C++ compiler on this system. Please specify one using environment variable CXX. See cmake_bootstrap.log for compilers attempted.

再次报错:缺少C++编译器。

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

重复上面的操作

[root@localhost cmake-2.8.4]# ./configue

[root@localhost cmake-2.8.4]# make

[root@localhost cmake-2.8.4]# make install

开始正式安装Mysql

添加mysql用户和用户组

[root@localhost ~]# groupadd mysql

[root@localhost ~]# useradd -r -g mysql mysql

下载mysql的源码包mysql-5.5.31.tar.gz

[root@localhost ~]# tar xzvf mysql-5.5.31.tar.gz

[root@localhost ~]# cd mysql-5.5.31

cmake运行

[root@localhost mysql-5.5.31]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

-- Running cmake version 2.8.10.2

-- MySQL 5.5.31

-- Packaging as: mysql-5.5.31-Linux-x86_64

-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:83 (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:127 (FIND_CURSES)

cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)

CMakeLists.txt:269 (MYSQL_CHECK_READLINE)

-- Configuring incomplete, errors occurred!

缺少Curses包,解决办法:remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

在CentOS下需要安装ncurses-devel

[root@localhost mysql-5.5.31]# yum install ncurses-devel

安装完毕,重新cmake运行

[root@localhost mysql-5.5.31]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

....................................................................

-- Performing Test HAVE_PEERCRED - Success

Warning: Bison executable not found in PATH

-- Configuring done

-- Generating done

-- Build files have been written to: /root/mysql-5.5.31

有一个警告,缺少Bison就安装一下

[root@localhost mysql-5.5.31]# yum install bison

删除CMakeCache.txt,重新cmake。接下来开始编译安装,时间有点稍长,可以干点别的看看财经新闻

[root@localhost mysql-5.5.31]# make && make install

修改目录权限

[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# chown -R root:mysql .

[root@localhost mysql]# chown -R mysql:mysql data

创建系统数据库的表

[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

cp配置文件

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

启动mysql

/usr/local/mysql/bin/mysqld_safe --user=mysql &

修改环境变量

[root@localhost ~]# vi .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin/

export PATH

unset USERNAME

如上面类似添加mysql路径

总结 centos 下安装很方便,因为yum已经给安装上了,缺依赖的时候会自动下载安装。

bitsCN.com

人气教程排行