Centos 5.5 安裝Mysql5.5過程
阿新 • • 發佈:2019-01-08
這幾天在centos下裝mysql,這裡記錄一下安裝的過程,方便以後查閱
Mysql5.5.37安裝需要cmake,5.6版本開始都需要cmake來編譯,5.5以後的版本應該也要裝這個。
安裝cmake
[[email protected] ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
[[email protected] ~]# tar xvf cmake-2.8.12.2.tar.gz
[[email protected] ~]# cd cmake-2.8.12.2
[[email protected] cmake-2.8.12.2]#./bootstrap
[[email protected] cmake-2.8.12.2]# make
[[email protected] cmake-2.8.12.2]# make install
安裝mysql
[[email protected] ~]# wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz
[[email protected] ~]# tar xvf mysql-5.5.37.tar.gz
[[email protected] ~]# cd mysql-5.5.37
[[email protected] mysql-5.5.37]# cmake ./
可能還會報這個錯,沒有就跳過
CMake Error at cmake/readline.cmake:83(MESSAGE): Curses library not found. Pleaseinstall appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-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:355 (MYSQL_CHECK_READLINE -- Configuring incomplete, errors occurred! See also "/root/my/mysql-5.5.37/CMakeFiles/CMakeOutput.log". See also"/root/my/mysql-5.5.37/CMakeFiles/CMakeError.log".
說明centos系統沒有ncurses-devel
[[email protected] ~]# wget http://invisible-island.net/datafiles/release/ncurses.tar.gz
[[email protected] ~]# cd ncurses-5.9
[[email protected] ncurses-5.9]#./configure
[[email protected] ncurses-5.9]# make
[[email protected] ncurses-5.9]# make install
再刪除剛才編譯生成的 CMakeCache.txt 檔案,否則無法進行下一步
[[email protected] mysql-5.5.37]# rm -f CMakeCache.txt
繼續編譯mysql
[[email protected] ~]# cmake ./
[[email protected] ~]# make
[[email protected] ~]# make install
這樣,mysql預設將成功安裝到/usr/local/mysql
建立mysql使用者組
[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd –r –g mysql mysql
[[email protected] ~]# chown –R mysql.mysql /usr/local/mysql
啟動mysql
[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql
這裡可能會發生錯誤,沒有就跳過:
FATAL ERROR: Could not find./bin/my_print_defaults
If you compiled from source, you need torun 'make install' to
copy the software into the correct locationready for operation.
If you are using a binary release, you musteither be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
解決方法:
[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
再啟動mysql
[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql
註冊mysql服務,開機自動啟動
1.設定mysql配置檔案到/etc目錄
[[email protected] ~]# cp /usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf
2.設定mysql開機自啟
[[email protected] ~]# cp/usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[[email protected] ~]# chmod +x /etc/init.d/mysql
[[email protected] ~]# /sbin/chkconfig --add mysql
3.啟動mysql服務
[[email protected] ~]# service mysql start
測試mysql是否安裝成功
[[email protected] ~]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.37 Source distribution
Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.03 sec)
參考: