日期:2014-05-16  浏览次数:20790 次

用源码编译安装MYSQL5.5到ubuntu10.10上

?

?

http://forum.ubuntu.org.cn/viewtopic.php?t=319886

用源码编译安装MYSQL5.5到ubuntu10.10上[手记]
鄙人初学乍练,写的不好,大家原谅~今天泡了下午论坛,没找到MYSQL的合适的安装配置教程,只好自己去看官方文档了,着实花了时间,
下列是我的操作过程,写出来,希望对大家能有点帮助。

下载地址,http://dev.mysql.com/downloads/mysql/
选择源码下载:source code
文件:mysql-5.5.9.tar.gz
下载后在下载目录
$ sudo tar zxvf mysql-5.5.9.tar.gz
查看文件夹下INSTALL-SOURCE文件,里面有各个系统的编译安装方式(英文)
注意,安装前应当注意安装工具的完善,否则编译的时候将出错,本帖稍后的部分给出了工具列表。这里先给出安装命令。
linux下源码的安装方式如下:

# 安装前配置
shell> groupadd mysql
shell> useradd -r -g mysql mysql

# 开始源码编译安装
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# 结束编译安装

# 初始化,下列命令使mysql得到对数据库文件的拥有权。mysql_install_db脚本能刷新授权表
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# 可选命令,配置文件位置更改,且内有五种配置模式。
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# 可选命令,自启动脚本,可以mysql自动启动。
shell> 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)
----------------------
如回显所示,ubuntu下安装libncurses5-dev;redhat下安装ncurses-devel,并删除当前目录CMakeCache.txt(必须删除,否则报错依旧)并重新运行:
$ cmake .
命令
----------------------
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/downloads/mysql-5.5.9
----------------------
一个警告总算不爽,如回显所见,安装bison。
$ sudo apt-get install bison
----------------------
这是两个比较多的问题。



问题总结:
后来查看了官方的文档,编译安装的时候工具必须要有下列5个。
=>安装工具:
1. cmake
----没有自己编译安装cmake
----shell:~$ sudo apt-get install cmake
----版本:2.8.2
2.GNU make
----Ubuntu自带
----版本:3.81
3.GCC
----Ubuntu自带
----版本:4.4.5(官方文档:必须3.2以上)
4.Perl
----Ubuntu自带
----版本:5.10.1
5.libncurses5-dev (ncurses-devel)
----若差了这个包,在cmake的时候会报错。
----Debian/Ubuntu上的包名是libncurses5-dev,RedHat和其他版本对应的是ncurses-devel
----shell:~$ sudo apt-get install libncurses5-dev




开启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

?

?

-------------------------------

kaqi补充

sudo apt-get install gettext
sudo apt-get install bison
sudo apt-get install build-essential

?

很遗憾,搞了老久,还是没有成功... ... 放弃。 用apt-get装mysql 5.1

?

Reinstalled on a new VM following the above steps. Now it works. So, there must be some remaing garbage from my previously deleted mysql 5.1.

?

?

Use the following command to install the mysql-client

sudo apt-get install my