編譯安裝mysql

來源:互聯網
上載者:User

標籤:資料庫管理   開發人員   

一、mysql簡介  

MySQL是一個開放源碼的小型關聯式資料庫管理系統,開發人員為瑞典MySQL AB公司,之後經曆SUN公司收購MySQL AB,Orance 公司收購SUM,所以目前mysql項目由Orance公司負責運營和維護。MySQL被廣泛地應用在Internet上的中小型網站中。由於其體積小、速度快、總體擁有成本低,尤其是開放源碼這一特點,許多中小型網站為了降低網站總體擁有成本而選擇了MySQL作為網站資料庫。

二、源碼編譯及安裝

(1)建立運行使用者

[[email protected] ~]# useradd -M -u 50 -s /sbin/nologin mysql


(2)解包

官方下載網站http://www.mysql.com

 在此我用的 mysql-5.1.55版本

[[email protected] ~]# tar xf mysql-5.1.55.tar.gz -C /usr/src/

[[email protected] ~]# cd /usr/src/mysql-5.1.55/

[[email protected] mysql-5.1.55]#


(3)配置

[[email protected] mysql-5.1.55]# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312

上述配置中 各選項的含義

>  --prefix:  將指定mysql資料庫程式安裝到哪個目錄,如/usr/local/mysql

>  --with-charset:  指定預設使用的字元集編碼,應與校隊規則相對應,如utf8

>  --with-collation:   指定預設使用的字元集校隊規則

>   --with-extra-charsets:  指定額外支援的其他字元集編碼,如gbk,gb232等


註:要進行一些小調整,才能編譯後獲得完整的支援,如修改include子檔案下的config.h檔案,添加相應編譯定義即可(預設存在,若不存在添加即可)

[[email protected] mysql-5.1.55]# vim include/config.h  

#define HAVE_CHARSET_gbk 1  

#define HAVE_CHARSET_gb2312 1    


(4)編譯安裝

[[email protected] mysql-5.1.55]# make && make install


三、其他調整

(1)建立設定檔

[[email protected] mysql-5.1.55]# cp support-files/my-medium.cnf /etc/my.cnf


(2)初始化資料庫

[[email protected] mysql-5.1.55]# cd /usr/local/mysql/bin/

[[email protected] bin]# ./mysql_install_db --user=mysql [--datadir=/mydata/data]  

[[email protected] bin]# chown -R root:mysql /usr/local/mysql/

[[email protected] bin]# chown -R mysql /usr/local/mysql/var/


(3)最佳化執行路徑,程式庫路徑

[[email protected] bin]# ln -s /usr/local/mysql/bin/*  /usr/local/bin/

[[email protected] bin]# ln -s /usr/local/mysql/lib/mysql/*  /usr/lib/

[[email protected] bin]# ln -s /usr/local/mysql/include/mysql/*  /usr/include/


(4)添加系統服務

[[email protected] bin]# cd /usr/src/mysql-5.1.55/

[[email protected] mysql-5.1.55]# cp support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql-5.1.55]# chmod +x /etc/init.d/mysqld 

[[email protected] mysql-5.1.55]# chkconfig --add mysqld

[[email protected] mysql-5.1.55]# /etc/init.d/mysqld start

[[email protected] mysql-5.1.55]# /etc/init.d/mysqld status


(5)啟動mysql,成功

[[email protected] ~]# service mysqld restart

Shutting down MySQL.                                 [確定]

Starting MySQL.                                            [確定]


(6)初始設定密碼

[[email protected] ~]# mysqladmin -u root password 123456


(7)進入mysql資料庫

[[email protected] ~]# mysql -u root -p123456

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.1.55-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 licenseType ‘help;‘ or ‘\h‘ for help.

Type ‘\c‘ to clear the current input statement.

mysql>


此時已經完成了mysql的搭建,接下來會在介紹mysql語句。

本文出自 “空懷感” 部落格,轉載請與作者聯絡!

編譯安裝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.