Linux下Mysql源碼安裝筆記

來源:互聯網
上載者:User

很長沒有寫點東西了,在工作的這些日子,得到了一些安裝Mysql的方法,此方法可以同時在一台Linux服務上安裝多個Mysql.

準備Mysql的源碼,版本號碼為Mysql-5.0.20a.tar.gz,當然其它的也行,只做為測試.Linux用Red Hat Linux as 4.

安裝步驟:

1.解壓Mysql-5.0.20a.tar.gz.

命令: tar -zxvf Mysql-5.0.20a.tar.gz

2.配置 Mysql

命令:./configure --prefix=/test/Mysql --with-charset=gbk

說明:安裝到/text/Mysql下,語言用gbk.當然用別的也行,還有其它參數可以查看相關文檔.

3.編譯,安裝

命令:

make

make install

這兩個命令發的時間較長.

4.建立使用者和組.

groupadd Mysql

useradd -g Mysql Mysql

5.進入Mysql目錄.建立var目錄.並把./share/Mysql/my-medium.cnf 拷到Mysql目錄下並改名為my.cnf.

>mkdir var

>mv share/Mysql/my-medium.cnf my.cnf

6.配置my.cnf

配置主要把安裝的目錄的那幾項開啟就行.

改動如下:

[client]
#password = your_password
port = 3306
socket = /tmp/Mysql3306.sock

# The Mysql server
[Mysqld]
port = 3306
socket = /tmp/Mysql3306.sock

開啟下面幾項

innodb_data_home_dir = /test/Mysql/var/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /test/Mysql/var/
innodb_log_arch_dir = /test/Mysql/var/

7.安裝資料庫

命令:./bin/Mysql_install_db --defaults-file=/test/Mysql/my.cnf --user=Mysql

說明:必須用參數--defaults-file指定my.cnf,否則系統用預設的/etc/my.cnf.

8.安裝完後,可以看到Mysql/var目錄下有資料檔案,然後用下面命令設定許可權:

shell> chown -R root .
shell> chown -R Mysql var
shell> chgrp -R Mysql .

9.啟動資料庫.

./bin/Mysqld_safe --defaults-file=/test/Mysql/my
.cnf --user=Mysql &

10.進入資料庫.

./bin/Mysql -u root --socket=/tmp/Mysql3306 --defaults-file=/test/Mysql/my.cnf

預設時沒有密碼,當然如果你刪除/etc/my.cnf,可以不要後面的--defaults-file=/test/Mysql/my.cnf
./bin/Mysql -u root --socket=/tmp/Mysql3306 也就行了,原因大家應該知道吧!^_^!

11.設為服務並自啟動.

對於設定為服務只要把Mysql/share/Mysql/Mysql.server放到/etc/init.d/下改名為Mysql

命令:

mv share/Mysql/Mysql.server /etc/init.d/Mysql

chmod 775 /etc/init.d/Mysql

chkconfig --add Mysql

總結,這隻是安裝了一個3306連接埠的Mysql,如果要在裝一個msyql,步驟一樣,只要改動my.cnf檔案的內容.

[client]
#password = your_password
port = 3310
socket = /tmp/Mysql3310.sock

# The Mysql server
[Mysqld]
port = 3310
socket = /tmp/Mysql3310.sock

假如有問題的話,可以發郵件.

聯繫我們

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