mysql安装笔记0822

来源:互联网 发布:天鹰行动20.d vb 编辑:程序博客网 时间:2024/05/27 20:11

1.下载mysql的源码安装包废了不少周折,最后直接在Google上搜mysql-5.5.tar.gz才在台湾的一个edu资源库中找到

2.rz -yeb到ubuntu上(之前装了SecureCRT)

3.解压并安装

tar zxvf mysql-5.5.27.tar.gzln -s /var/lib/ureadahead/debugfs/mysql-5.5.27 /usr/local/mysqlcd /usr/local/mysql./configure

结果发现生成不了makefile文件,Google发现MySQL从5.5开始需要使用cmake来编译,于是走第四步

4.下载cmake-2.8.11.2.tar.gz,解压并安装cmake

tar zxvf cmake-2.8.11.2.tar.gzcd /var/lib/ureadahead/debugfs/cmake-2.8.11.2./configuremakemake install
makemake install


在安装cmake的过程当中,遇到了一个麻烦

root@ubuntu:/var/lib/ureadahead/debugfs/cmake-2.8.11.2# ./configure ---------------------------------------------CMake 2.8.11.2, Copyright 2000-2012 Kitware, Inc.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.---------------------------------------------Log of errors: /var/lib/ureadahead/debugfs/cmake-2.8.11.2/Bootstrap.cmk/cmake_bootstrap.log---------------------------------------------

根据前人经验,这是缺少c++编译器造成的,于是安装g++

sudo apt-get install g++

遗憾的是,依然报错,怀疑是gcc库没有下载,直接到ubuntu的更新安装包的窗口更新所有安装包,更新完后,重新在cmake目录./configure,成功生成makefile文件

makemake install

安装好cmake后,给MySQL增加data目录和添加用户

mkdir -p /usr/local/mysql/data/groupadd mysqluseradd -r -g mysql mysql

到MySQL的目录下使用cmake编译生成MySQL的makefile

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

报错了

-- 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:268 (MYSQL_CHECK_READLINE)-- Configuring incomplete, errors occurred!

缺少libnureses5-dev库,下载安装一下

sudo apt-get install libncurses5-dev

报错

dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

根据Stack Overflow的牛人解答,使用下面的方式来下载安装libnureses5-dev库

sudo aptitude install libncurses5-dev

继续报错

dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

另一位牛人提示还需要清空dpkg的更新目录

rm -rf /var/lib/dpkg/updates

再下载安装libnureses5-dev库,还是报错

Do you want to continue? [Y/n/?] yWriting extended state information... Donedpkg: cannot scan updates directory `/var/lib/dpkg/updates/': No such file or directoryE: Sub-process /usr/bin/dpkg returned an error code (2)A package failed to install.  Trying to recover:dpkg: cannot scan updates directory `/var/lib/dpkg/updates/': No such file or directoryReading package lists... Done             Building dependency tree       Reading state information... DoneReading extended state information      Initializing package states... Done

很明显,刚才我清理dpkg数据的时候,把updates目录也干掉了

mkdir -p /var/lib/dpkg/updates

再下载安装,success,清除cmake编译过程产生的信息

rm -f CMakeCache.txt

再重新执行cmake编译过程,报

Warning: Bison executable not found in PATH

需要下载安装bison库

sudo aptitude install bison

安装ok,此时,可以发现mysql目录下已经生成makefile文件

makemake install

设置目录权限

chown root:mysql * -R chown mysql:mysql data -R

将mysql的启动服务添加到系统服务中

cp support-files/my-medium.cnf /etc/my.cnf

创建系统数据库表

scripts/mysql_install_db --user=mysql

设置环境变量

vi /root/.bash_profilePATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/libsource /root/.bash_profile

启动MySQL

 ./bin/mysqld_safe --user=mysql &

大功告成