当前位置:Gxlcms > mysql > CentOS下编译安装mysql5.5.10

CentOS下编译安装mysql5.5.10

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

MySQL 5.5.10 for Linux 安装 操作系统:CentOS 5.5 MySQL:5.5.10 su - 利用 CentOS 系统自带的 yum 命令安装、升级所需的程序库 sudo -s LANG=C yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-develfreetype freetype-devel lib

·MySQL 5.5.10 for Linux 安装

操作系统:CentOS 5.5

MySQL:5.5.10

su -

利用CentOS 系统自带的yum命令安装、升级所需的程序库
sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

#先下载cmake

wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

安装cmake

#tar –xzvf cmake-2.8.4.tar.gz

#cd cmake-2.8.4

#./configure

#make

#make install

1.创建MySQL用户名及组

#groupadd mysql

#useradd -g mysql mysql

2.下载mysql 5.5.10

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

#tar –xzvf mysql-5.5.10.tar.gz

#cd mysql-5.5.10.tar.gz

开始编译并安装

#/usr/local/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ -DMYSQL_DATADIR=/usr/local/webserver/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/usr/local/webserver/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0

#make && make install

初始化,下列命令使mysql得到对数据库文件的拥有权。mysql_install_db脚本能刷新授权表
# cd /usr/local/mysql
# chown -R mysql .
# chgrp -R mysql .
# scripts/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql data

可选命令,配置文件位置更改,且内有五种配置模式。
# cp support-files/my-medium.cnf /etc/my.cnf
# bin/mysqld_safe --user=mysql &
可选命令,自启动脚本,可以mysql自动启动。
# cp support-files/mysql.server /etc/init.d/mysql.server

遇到的问题:
----------------------------------------------------------

-- MySQL 5.5.9

-- 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:256 (MYSQL_CHECK_READLINE)

解决:安装ncurses-devel,并删除当前目录CMakeCache.txt(必须删除,否则报错依旧)并重新运行。

开启mysql
cd . ; ./bin/mysqld_safe &
当然你用root命令开启的时候,应当使用--user参数,这样才是安全的启动方式。
cd . ; ./bin/mysqld_safe --user=mysql &

root和你的用户名设置密码,这需要在你先启动mysql的基础上,否则会报错,说你没有连接到端口:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h YourusernamE password 'new-password'
也可一用下命令替代:
./bin/mysql_secure_installation

人气教程排行