linux 下安裝 源碼安裝mysql

來源:互聯網
上載者:User

標籤:linux   mysql   源檔案   

Linux安裝mysql——源碼安裝

1.假設已經有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz兩個源檔案

(1)先安裝cmake(mysql5.5以後是通過cmake來編譯的)

[[email protected] rhel5 local][[email protected] rhel5 local][[email protected] rhel5 cmake-2.8.4][[email protected] rhel5 cmake-2.8.4][[email protected] rhel5 cmake-2.8.4]


(2)建立mysql的安裝目錄及資料庫存放目錄

[[email protected] rhel5~][[email protected] rhel5~]

(3)建立mysql使用者及使用者組

[[email protected] rhel5~]groupadd mysql[[email protected] rhel5~]useradd -r -g mysql mysql

(4)安裝mysql

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

[[email protected] rhel5 local][[email protected] rhel5 local][[email protected] rhel5 mysql-5.5.10]-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1[[email protected] rhel5 mysql-5.5.10][[email protected] rhel5 mysql-5.5.10]

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

參數說明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql        //安裝目錄

-DINSTALL_DATADIR=/usr/local/mysql/data         //資料庫存放目錄

-DDEFAULT_CHARSET=utf8                        //使用utf8字元

-DDEFAULT_COLLATION=utf8_general_ci            //校正字元

-DEXTRA_CHARSETS=all                            //安裝所有擴充字元集

-DENABLED_LOCAL_INFILE=1                        //允許從本地匯入資料

 

注意事項:

重新編譯時間,需要清除舊的對象檔案和緩衝資訊。

# make clean

# rm -f CMakeCache.txt

# rm -rf /etc/my.cnf

2.配置

(1)設定目錄許可權

[[email protected] rhel5~][[email protected] rhel5 mysql][[email protected] rhel5 mysql]

(2)

[[email protected] rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //將mysql的啟動服務添加到系統服務中



(3)建立系統資料庫的表

[[email protected] rhel5 mysql][[email protected] rhel5 mysql]

(4)設定環境變數

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

[[email protected] rhel5~]在PATH=:/bin添加參數為:PATH=:/bin:/usr/local/mysql/bin:/usr/local/mysql/lib[[email protected] rhel5~]

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

(5)手動啟動mysql

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

[[email protected] rhel5~][[email protected] rhel5 mysql]開機記錄寫在此檔案下:/usr/local/mysql/data/localhost.err關閉MySQL服務[[email protected] rhel5 mysql]

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

(6)另一種簡單的啟動mysql的方法(mysql已經被添加到系統服務中)

[[email protected] rhel5~][[email protected] rhel5~][[email protected] rhel5~]

如果上述命令出現:mysql.server 未識別的服務

則可能mysql還沒添加到系統服務中,下面用另一種方法添加:

[[email protected] rhel5 mysql]# cp support-files/mysql.server  /etc/init.d/mysql //將mysql的啟動服務添加到系統服務中

注意:主要是將mysql.server拷貝到/etc/init.d中,命名為mysql。在有的系統中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系統中,mysql.server在/usr/local/mysql/support-files/mysql.server中。

然後再用#service mysql start 來啟動mysql即可。


(7)修改MySQL的root使用者的密碼以及開啟遠端連線

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

[[email protected] rhel5~]mysql>use mysql;mysql>desc user;mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY ;  //為root添加遠端連線的能力。mysql>update user set Password = password(‘xxxxxx‘) where User=‘root‘;mysql>select Host,User,Password  from user where User=‘root‘; mysql>flush privileges;mysql>exit重新登入:mysql -u root -p若還不能進行遠端連線,則關閉防火牆[[email protected] rhel5~]

650) this.width=650;" src="%5C" alt="\"複製代碼\"" />

註:如果不能遠端連線,出現錯誤mysql error number 1130,則加入下面語句試試:

mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘******‘ WITH GRANT OPTION;


本文出自 “json在php中的使用” 部落格,請務必保留此出處http://zhaozhangxiao.blog.51cto.com/10609825/1880826

linux 下安裝 源碼安裝mysql

聯繫我們

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