【MySQL源碼】源碼安裝和啟動mysql

來源:互聯網
上載者:User

標籤: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.9sudo makesudo make install
sudo ln -s /usr/local/etc/cmake-2.8.9/bin/cmake /usr/local/bin/cmake

 現在可以使用cmake命令了!

如果出現以下提示,請先安裝g++。

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

ubuntu下用

sudo apt-get install g++

redhat系列下用

sudo yum install gcc-c++

 

下載最新的mysql源碼包,解壓後,進入其跟目錄

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

如果編譯過程出現如下錯誤 需安裝libncurses5-dev

-- 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!
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("");即可解決問題。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.