標籤:
1.先檢查系統有沒有安裝mysql
[[email protected] opt]# rpm -qa|grep mysql
# 我們看到,並沒有安裝mysql,但是有一個mysql的libs開發包外掛程式,他是幹什麼的呢?
# 解釋:由於CentOS6.4系統內建就有postfix服務,而這個mysql-libs呢就是支援這個postfix服務的,如果我們不使用到postfix,那就卸載掉吧,而且每一個mysql-server安裝的時候,後內建安裝上這個mysql-libs。
#刪除mysl-;ib,系統就乾淨了
[[email protected] opt]# yum remove mysql-libs
2 下載mysql-5.6.21.tar.gz, 我們準備安裝在/user/local 資料放在/uer/local/data 下
[[email protected] ~]# groupadd mysql #建立使用者組mysql[[email protected] ~]# useradd -g mysql mysql -s /bin/false #建立使用者mysql 不能遠程登入[[email protected] ~]# mkdir /usr/local/mysql[[email protected] ~]# mkdir /usr/local/mysql/data[[email protected] ~]# cp mysql-5.6.21.tar.gz /usr/local
[[email protected] ~]# cd /usr/local/
[[email protected] local]# tar -xzvf mysql-5.6.21.tar.gz #解壓
#安裝cmake編譯環境和依賴包
[[email protected] local]# yum -y install make gcc-c++ cmake openssl openssl-devel bison-devel ncurses ncurses-devel wget perl perl-devel
3.開始編譯安裝mysql
cmake --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DENABLE_PROFILING=1 -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
[[email protected] mysql-5.6.21]# make && make install #等待較長時間
[[email protected] mysql-5.6.21]# make clean #安裝完後 清理一下臨時檔案
4.配置mysql
[[email protected] local]# chown -R mysql:mysql /usr/local/mysql #修改mysql目錄的所屬使用者權限
#初始化指令碼
[[email protected] data]# cd mysql/data
[[email protected] data]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
#設定mysql服務開機自動啟動
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysql[[email protected] mysql]# chkconfig mysql on[[email protected] mysql]# service mysql start Starting MySQL. SUCCESS![[email protected] mysql]#
[[email protected] mysql]# vim /etc/profile #修改環境變數 使得可以使用mysql命令 PATH添加/usr/local/mysql/bin[[email protected] mysql]# source /etc/profile #使得設定檔生效[[email protected] mysql]# mysql -uroot #使用root(這時沒有密碼)登入Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.21 Source distributionCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
mysql> SET PASSWORD = PASSWORD(‘123456‘); #修改root使用者的密碼mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION; #root使用者使用密碼‘passwprd‘遠程登入
Centos伺服器搭建(4)——安裝mysql