CentOS 5.4編譯安裝MySQL(VPS,小記憶體最佳化)

來源:互聯網
上載者:User

1、安裝編譯環境

1 yum install gcc gcc-c++ autoconf automake ncurses-devel 

2、下載,解壓縮

1 wget http://mysql.mirror.tw/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz
2 tar -xzvf mysql-5.1.45.tar.gz

3、編譯

1 CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \
2 -fno-exceptions -fno-rtti" ./configure \
3 --prefix=/usr/local/mysql --enable-assembler \
4 --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
5 --with-mysqld-ldflags=-all-static \
6 --with-client-ldflags=-all-static \
7 --with-extra-charsets=all \
8 --without-debug --with-charset=utf8 \
9 --with-collation=utf8_general_ci \
10 --with-pthread --enable-static \
11 --enable-thread-safe-client

完成後會提示"Thank you for choosing MySQL!"

1 make

最後會提示“make all win…”

1 make install

4、添加使用者,安裝資料庫

1 useradd mysql
2 passwd mysql #設定密碼,例如mysql123
3
4 cd /usr/local/mysql/
5 chown -R mysql:mysql ./
6
7 #安裝資料庫,添加預設mysql配置
8 ./bin/mysql_install_db --user=mysql
9 cp share/mysql/my-medium.cnf /etc/my.cnf

4、配置、開機自啟動

1 #經過上述配置後,mysql應該就可以正常啟動了
2 ./bin/mysqld_safe --user=mysql &
3
4 #下面我們來設定開機啟動mysql
5 kill掉上述測試進程(一般是兩個mysqld_safe是一個shell,它來啟動mysqld的daemon)
6 cp share/mysql/mysql.server /etc/init.d/mysqld
7 chkconfig --add mysqld
8 chkconfig --level 2345 mysqld on
9 #之後可以用service mysqld start啟動,開機會自動啟動

5、my.cnf參數調優

1 vim /etc/my.cnf

6、安全配置

1 #設定root密碼
2 mysqladmin -u root password ‘new-password’
3
4 #刪除test資料庫、匿名帳戶
5 mysql -u root -p
6 mysql> DROP DATABASE test;                            [刪除test資料庫]
7 mysql> DELETE FROM mysql.user WHERE user = '';        [刪除匿名帳戶]
8 mysql> FLUSH PRIVILEGES;                              [重載許可權]

7、小記憶體最佳化

只要不開InnoDB,my-medium.cnf 一般可以保證很小的記憶體佔用和較高的效能了,具體的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.