mysql在linux上的安裝之二(mysql原始碼安裝)

來源:互聯網
上載者:User

標籤:dev   方法   mysql使用者   storage   模糊   查詢系統   enter   mysqld   ora   


1.下載對應的mysql安裝原始碼包
    地址為:http://dev.mysql.com/downloads/mysql/5.1.html

2.假設曾經安裝過則卸載無用過舊的已安裝的mysql
    因為非常多linux發行版,都預裝了對應的mysql,一般都是rpm形式的安裝,且mysql的版本號碼都是比較低的(這個可能是因為相容性測試的考慮吧)。因此在自己親自安裝mysql之前,請先卸載這些過舊的mysql,保證我們系統的“純淨”。
    使用例如以下命令查詢系統中安裝的mysql:
    rpm -qa|grep mysql
    此命令會模糊比對軟體名有mysql的rpm安裝包,列出來的這些都能夠把他們刪掉,一次性刪掉,可使用例如以下的一個指令碼命令:
    for i in `rpm -qa | grep "mysql"`; do rpm -e --allmatches $i; done
    運行完上面命令後。假設還有頑固分子沒有被刪除。那就一個一個利用以下的命令來刪除:
  rpm -e --allmatches packet-name
    假設發現循環相依性問題,那麼packet-name就列出這些循環相依性的安裝包。一次性所有刪除,如:
[[email protected] root]# rpm -e --allmatches mysql


安裝源碼版本號碼的MySQL
3.加入mysql使用者組
 groupadd mysql
 
4.加入mysql使用者,並指定到mysql使用者組
 useradd -g mysql mysql
 
5.解壓縮mysql-version.tar.gz
 gunzip < mysql-VERSION.tar.gz | tar -xvf -

6.安裝mysql
 cd mysql-VERSION
 ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charsets=armscii8,ascii,big5,cp1250,cp1251,cp1256,cp1257,cp850,cp852,cp866,cp932,dec8,eucjpms,euckr,gb2312,gbk,geostd8,greek,hebrew,hp8,keybcs2,koi8r,koi8u,latin1,latin2,latin5,latin7,macce,macroman,sjis,swe7,tis620,ucs2,ujis,utf8 --with-plugins=innodb_plugin
 make
 make install
 
7.複製設定檔
shell> cp support-files/my-medium.cnf /etc/my.cnf
 
8.運行mysql系統資料庫初始化指令碼
 cd /usr/local/mysql
 bin/mysql_install_db --user=mysql
 
9.設定mysql安裝資料夾許可權,設定owner為mysql
 chown -R mysql var
 chgrp -R mysql .
 
10.啟動mysql應用
 /usr/local/mysql/bin/mysqld_safe --user=mysql &
 
11.設定rootpassword(資料庫的DBA)
 bin/mysqladmin -u root password ‘root’
 
12.登入mysql
 bin/mysql -uroot -p
Enter password:
登入成功會看到:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 229
Server version: 5.1.40-log MySQL Community Server (GPL)
 
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
 
mysql>
 
這時mysql已經裝好了,能夠查看資料庫了,但在正式使用資料庫開發與部署的時候還須要做一些工作:

1.設定設定檔my.cnf

    依照需求copy my-***.cnf到/etc/my.cnf

2.改動預設字元集utf8

    (1).[client]下增加default-character-set=utf8
    (2).[mysqld]下增加default-character-set=utf8

#不修改儲存引擎的話。3、4步能夠略過
3.啟動InnoDB引擎的方法例如以下:
    1)關閉mysql的服務
    2)改動my.ini
        將default-storage-engine=INNODB前的凝視(#)去掉
        將skip-innodb這行凝視(加上#)

4.配置innodb參數
     1).找到# Uncomment the following if you are using InnoDB tables
        去掉innodb_*下的全部#

     2).假設安裝mysql的檔案夾不是預設的。則須要改動
        # mysql 預設安裝資料夾為 /usr/local/mysql/
        # mysql 預設資料表空間檔案夾安裝資料夾為 /usr/local/mysql/var/

        innodb_data_home_dir=/usr/local/database/mysql/var/
        innodb_log_group_home_dir=/usr/local/database/mysql/var/
     3).儲存後重新啟動mysql服務。

5.設定系統服務

    讓linux啟動的時候就啟動mysql服務
shell> cd /usr/local/mysql/
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> chmod 777 /etc/init.d/mysql
shell> chkconfig --add mysql
shell> chkconfig --level 35 mysql on
 
6.重新啟動MySQL服務
shell> service mysql restart

mysql在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.