Linux下yum和源碼安裝Mysql資料庫步驟

來源:互聯網
上載者:User

環境:CentOS 6.0_x64

開放連接埠:編輯/etc/sysconfig/iptables添加以下記錄,儲存後重啟防火牆


-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

一、方法一:yum安裝

1. 安裝 # yum -y install mysql-server mysql-devel mysql


二、方法二:源碼編譯安裝

建立使用者、目錄和修改許可權

# mkdir -p /usr/local/mysql/data
# groupadd mysql
# useradd -g mysql mysql
# chown -R mysql.mysql /usr/local/mysql/data/

安裝所需相關庫檔案

# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake
解壓mysql-5.5.27.tar.gz
# cd /home/software/
# tar -zxv mysql-5.5.27.tar.gz

編譯安裝

# cd mysql-5.5.27
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
# make && make install
# cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf

初始化資料庫

# cd /usr/local/mysql/
# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

設定開機啟動

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig mysqld on

添加環境變數

# echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
# source /etc/profile

啟動mysql服務

# /etc/init.d/mysqld start

聯繫我們

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