用源码编译安装MYSQL5.5到ubuntu10.10上
-
- 帖子: 53
- 注册时间: 2009-05-14 21:14
用源码编译安装MYSQL5.5到ubuntu10.10上
用源码编译安装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
鄙人初学乍练,写的不好,大家原谅~今天泡了下午论坛,没找到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
- drvicar
- 帖子: 1285
- 注册时间: 2007-12-17 18:07
- 来自: 西安
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
先顶一下 哈哈
-
- 帖子: 54
- 注册时间: 2010-01-16 13:17
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
总结得不错。顶下。我以前,曾花了一周的时间来安装MySQL。结果很悲剧。后来还是通过源代码的方式。自己看英文文档来安装的。
当时也没有来得及总结!呵呵。
当时也没有来得及总结!呵呵。
-
- 帖子: 22
- 注册时间: 2010-12-17 21:19
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
支持,一起学习!
-
- 帖子: 39
- 注册时间: 2010-06-03 13:59
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
支持啊,学习啊
-
- 帖子: 79
- 注册时间: 2006-03-25 21:33
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
请问楼主,show databases; 命令,显示出的默认数据库有几个?数据库的名字。
- 雨坤毅
- 帖子: 232
- 注册时间: 2010-08-28 14:34
- 系统: ArchLinux
- 联系:
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
mysql是安装在/usr/local/mysql下的,可以创建链接移动带其他地方去...
- TeliuTe
- 论坛版主
- 帖子: 7668
- 注册时间: 2007-11-25 13:29
- 系统: 16/18/20/w7
- 来自: 新疆博乐
- 联系:
- link_01
- 帖子: 1024
- 注册时间: 2008-11-05 13:24
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
这是上次匆忙之中安装mysql时通过手册和google混合的编译参数
[bash]CFLAGS="-O3" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" \
./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/data \
--enable-assembler \
--enable-thread-safe-client \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--without-debug \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-mysqld-user=mysql \
--with-extra-charsets=gbk,latin1 \
--with-pthread \
--with-innodb \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--without-docs \
--without-man
[/bash]
我来改一下:
CFLAGS="-O3" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti"
export CFLAGS CXX CXXFLAGS
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/data \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG=0 \
-DWITH_EXTRA_CHARSETS=gbk,latin1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_USER=mysql
-DWITH_INNOBASE_STORAGE_ENGINE=1
[bash]CFLAGS="-O3" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" \
./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/data \
--enable-assembler \
--enable-thread-safe-client \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--without-debug \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-mysqld-user=mysql \
--with-extra-charsets=gbk,latin1 \
--with-pthread \
--with-innodb \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--without-docs \
--without-man
[/bash]
我来改一下:
CFLAGS="-O3" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti"
export CFLAGS CXX CXXFLAGS
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/data \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG=0 \
-DWITH_EXTRA_CHARSETS=gbk,latin1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_USER=mysql
-DWITH_INNOBASE_STORAGE_ENGINE=1
笔记
-------------------------------------
http://blog.163.com/wqt_1101
-------------------------------------
http://blog.163.com/wqt_1101
-
- 帖子: 47
- 注册时间: 2010-05-14 16:06
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
[ 78%] Built target gen_lex_hash
[ 78%] Built target mysql_tzinfo_to_sql
[ 78%] Built target GenServerSource
[ 78%] Built target partition
[ 99%] Built target sql
[100%] Built target mysqld
[100%] Built target udf_example
[100%] Built target my_safe_process
Install the project...
-- Install configuration: "RelWithDebInfo"
CMake Error at cmake_install.cmake:36 (FILE):
file cannot create directory: /usr/local/mysql/docs. Maybe need
administrative privileges.
make: *** [install] 错误 1
为什么我就在make install的时候出现上述错误
[ 78%] Built target mysql_tzinfo_to_sql
[ 78%] Built target GenServerSource
[ 78%] Built target partition
[ 99%] Built target sql
[100%] Built target mysqld
[100%] Built target udf_example
[100%] Built target my_safe_process
Install the project...
-- Install configuration: "RelWithDebInfo"
CMake Error at cmake_install.cmake:36 (FILE):
file cannot create directory: /usr/local/mysql/docs. Maybe need
administrative privileges.
make: *** [install] 错误 1
为什么我就在make install的时候出现上述错误
-
- 帖子: 117
- 注册时间: 2010-01-08 16:33
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
很好,我正想安装,谢谢
-
- 帖子: 32
- 注册时间: 2010-02-01 22:08
- 联系:
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
sudo make installalanlhy 写了:[ 78%] Built target gen_lex_hash
[ 78%] Built target mysql_tzinfo_to_sql
[ 78%] Built target GenServerSource
[ 78%] Built target partition
[ 99%] Built target sql
[100%] Built target mysqld
[100%] Built target udf_example
[100%] Built target my_safe_process
Install the project...
-- Install configuration: "RelWithDebInfo"
CMake Error at cmake_install.cmake:36 (FILE):
file cannot create directory: /usr/local/mysql/docs. Maybe need
administrative privileges.
make: *** [install] 错误 1
为什么我就在make install的时候出现上述错误
I code.
liuyix.org
liuyix.org
-
- 帖子: 3
- 注册时间: 2010-05-08 17:29
Re: 用源码编译安装MYSQL5.5到ubuntu10.10上
本人OS版本:ubuntu 12.04
GCC版本:4.6.3
使用mysql-5.5.25编译,使用楼主的方法,安装curses库之后cmake可以过,但是make的时候出错,说是代码中类型转换出问题,
然后换乘mysql-5.6.15编译,顺利通过。
不知道这是mysql的问题还是gcc的问题
GCC版本:4.6.3
使用mysql-5.5.25编译,使用楼主的方法,安装curses库之后cmake可以过,但是make的时候出错,说是代码中类型转换出问题,
然后换乘mysql-5.6.15编译,顺利通过。
不知道这是mysql的问题还是gcc的问题