CentOS 5.5下安裝MySQL 5.5全過程分享_Mysql

來源:互聯網
上載者:User

開啟終端

切換到根目錄

[shell@localhost ~]# su -安裝Mysql5.5之前先卸載CentOS內建的Mysql5.0。

[root@localhost ~]# yum remove mysql

安裝cmake

下載cmake源碼包cmake-2.8.5.tar.gz

[root@localhost ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz編譯安裝[root@localhost]# tar xzvf cmake-2.8.5.tar.gz [root@localhost]# cd cmake-2.8.5 [root@localhost cmake-2.8.5]# ./bootstrap Error when bootstrapping CMake: Cannot find appropriate C compiler on this system. Please specify one using environment variable CC. See cmake_bootstrap.log for compilers attempted. 報錯:缺少C的編譯器。

解決方案:安裝gcc編譯器

可以從Linux系統的安裝盤中安裝,也可以簡單地用yum安裝

[root@localhost ~]# yum install gcc

繼續cmake的安裝

[root@localhost cmake-2.8.5]# ./bootstrap 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. 再次報錯:缺少C++編譯器。

安裝gcc-c++編譯器

同樣可以從Linux系統的安裝盤中安裝,或者簡單地用yum安裝

[root@localhost ~]# yum install gcc-c++

重複上面的操作

[root@localhost cmake-2.8.5]# ./bootstrap

沒有報錯後,編譯安裝

[root@localhost cmake-2.8.5]# make [root@localhost cmake-2.8.5]# make install[root@localhost cmake-2.8.5]# cmake -version

開始正式安裝Mysql

添加mysql使用者和使用者組

[root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -g mysql mysql

下載mysql的源碼包mysql-5.5.27.tar.gz

[root@localhost ~]# wget http://dev.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz解壓

[root@localhost ~]# cd /usr/local/[root@localhost local]# tar xzvf mysql-5.5.27.tar.gz[root@localhost local]# cd mysql-5.5.27

cmake運行

[root@localhost mysql-5.5.27]# cmake .

報錯:

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

解決辦法:

[root@localhost mysql-5.5.27]# rm CMakeCache.txt [root@localhost mysql-5.5.27]# yum -y install ncurses-devel*

重新cmake運行

[root@localhost mysql-5.5.27]# cmake .還是有個警告

Warning: Bison executable not found in PATH有一個警告,也解決了它,缺少Bison就安裝一下

[root@localhost mysql-5.5.27]# yum install bison

再次運行,沒有報錯

[root@localhost mysql-5.5.27]# cmake .在編譯安裝前,可以設定安裝的配置選項

[root@localhost mysql-5.5.27]# ./configure --help根據協助資訊選擇自己需要設定的選項,當然也可以跳過這步,按預設設定


#開始編譯安裝,時間有點稍長...

[root@localhost mysql-5.5.27]# make && make install完成編譯安裝

進入安裝目錄,將程式二進位的所有權改為root,資料目錄的所有權改為mysql使用者,更新授權表

[root@localhost mysql-5.5.27]# cd /usr/local/mysql[root@localhost mysql]# chown -R root . [root@localhost mysql]# chown -R mysql . [root@localhost mysql]# chgrp -R mysql . [root@localhost mysql]# scripts/mysql_install_db --user=mysql 初始化資料庫[root@localhost mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 安全啟動mysql

[root@localhost mysql]# ./bin/mysqld_safe --user=mysql關閉mysql

[root@localhost mysql]# ./bin/mysqladmin -u root shutdown -p預設密碼為空白方便調用,為mysql設定一個軟連結[root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

其他設定處理:

設定選項檔案,將設定檔拷貝到/etc下

[root@localhost mysql]# cp support-files/my-medium.cnf /etc/mysql.cnf 設定開機自啟動[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql [root@localhost mysql]# chmod +x /etc/init.d/mysql [root@localhost mysql]# chkconfig –add mysqld[root@localhost mysql]# chkconfg mysqld on

現在可以通過服務來啟動和關閉Mysql伺服器

[root@localhost ~]# service mysql start [root@localhost ~]# service mysql shutdown

串連伺服器

[root@localhost ~]# mysql -u root -pyourpasswordWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3 to server version: 5.5.27 Source distributinoType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> ...mysql> 提示符告訴你mysql準備為你輸入命令。

至此MySQL已經正常安裝並可以使用

mysql> QUIT

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.