码迷,mamicode.com
首页 > 数据库 > 详细

【MySQL源码】源码安装和启动mysql

时间:2014-08-19 20:48:55      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   os   io   数据   

--【MySQL源码】源码安装和启动mysql

--------------------------------------2014/08/19

本机环境:ubuntu12.04,fedora-17

MYSQL版本:5.5.28

CMAKE版本:2.8.9

一.下载最新版本的cmake,解压后编译安装.

sudo ./configure --prefix=/usr/local/etc/cmake-2.8.9
sudo make
sudo make install
sudo ln -s /usr/local/etc/cmake-2.8.9/bin/cmake /usr/local/bin/cmake

 现在可以使用cmake命令了!

如果出现以下提示,请先安装g++。

bubuko.com,布布扣
---------------------------------------------
CMake 2.8.9, Copyright 2000-2011 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: /usr/local/src/cmake-2.8.9/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
bubuko.com,布布扣

ubuntu下用

sudo apt-get install g++

redhat系列下用

sudo yum install gcc-c++

 

下载最新的mysql源码包,解压后,进入其跟目录

bubuko.com,布布扣
sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/etc/mysql-5.5.28 \  
-DMYSQL_DATADIR=/usr/local/etc/mysql-5.5.28/data \   
-DEXTRA_CHARSETS=all \  
-DDEFAULT_CHARSET=utf8 \  
-DDEFAULT_COLLATION=utf8_general_ci \ 
-DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \  
-DWITH_INNOBASE_STORAGE_ENGINE=1 \

# 这里附上一行版的,方便粘贴
# 注:此处路径为/opt下,如果要和上面保持一致,请手动修改
# sudo cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql-5.5.28 -DMYSQL_DATADIR=/opt/mysql-5.5.28/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1

sudo make
sudo make install
bubuko.com,布布扣

如果编译过程出现如下错误 需安装libncurses5-dev

bubuko.com,布布扣
-- 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!
bubuko.com,布布扣
sudo apt-get install libncurses5-dev
#删除编译缓存信息
sudo rm -rf CMakeCache.txt

 编译完成后创建数据库

./scripts/mysql_install_db --user=root --basedir=/opt/mysql-5.5.28/ --datadir=/opt/mysql-5.5.28/data/

创建完成后就可以启动数据库了

./bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/opt/mysql-5.5.28/data/ --basedir=/opt/mysql-5.5.28/ --port=20120 --user=root&

 

不知道是否是因为最新版本mysql 5.7的限制,我使用忽略权限表的方式登录数据库后,将密码修改为空,然后重启mysqld,再已空密码登录成功。

而后进行查询和创建数据库操作,报以下错误:

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

通过:set password=password("");即可解决问题。

【MySQL源码】源码安装和启动mysql,布布扣,bubuko.com

【MySQL源码】源码安装和启动mysql

标签:style   blog   http   color   使用   os   io   数据   

原文地址:http://www.cnblogs.com/jackhub/p/3922976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!