安裝和配置mysql

來源:互聯網
上載者:User

標籤:web伺服器   target   blank   mysql   style   

一:安裝mysql

1.在web伺服器上安裝mysql:

yum -y remove mysql mysql-server ##卸載mysql的rpm包

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQHLhWV2AAAAO-yNc86k696.png" "244" height="17" />

mount /dev/cdrom /mnt

yum -y install ncurses-*

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQHKwlVQfAAAOIWFMNZc467.png" "244" height="15" />

lftp ftp.linuxfan.cn ##下載mysql和cmake

lftp ftp.linuxfan.cn:/tools> get cmake-2.8.6.tar.gz mysql-5.5.22.tar.gz

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://s3.51cto.com/wyfs02/M02/86/C1/wKioL1fJQHOROxn2AAATWTHWVNU343.jpg" "244" height="38" />

2.解壓cmake,安裝基礎環境

tar zxvf /root/cmake-2.8.6.tar.gz -C /usr/src/

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQHTxbwNBAAAJBbbXRZY885.jpg" "244" height="14" />

cd /usr/src/cmake-2.8.6

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image007" border="0" alt="clip_image007" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQHSSxM75AAANMsTu_V8811.png" "244" height="17" />

3.配置,編譯安裝cmake

./configure &&gmake &&gmake install

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image009" border="0" alt="clip_image009" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQHXSB9qcAAAJV1_rqqY011.jpg" "244" height="14" />

4.解壓mysql

tar zxvf /root/mysql-5.5.22.tar.gz -C /usr/src/

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image011" border="0" alt="clip_image011" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQHWxwuWdAAALqAU9TsQ592.jpg" "244" height="19" />cd /usr/src/mysql-5.5.22/

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQHaT6u32AAAOylvOTtc888.png" "244" height="15" />5.使用cmake進行配置mysql

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #指定安裝目錄\

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image014" border="0" alt="clip_image014" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQHfh-tAvAAAJgBsc6-A454.jpg" "244" height="20" />

-DDEFAULT_CHARSET=utf8 #指定字元集為utf8 \

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image016" border="0" alt="clip_image016" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQHfjyITLAAASMCMiOQU991.jpg" "244" height="41" />

-DDEFAULT_COLLATION=utf8_general_ci ##指定字元校正 \

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image018" border="0" alt="clip_image018" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQHjwjhnGAAAQ3QMQNSo114.jpg" "244" height="44" />

-DWITH_EXTRA_CHARSETS=all ##支援額外字元集\

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image020" border="0" alt="clip_image020" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQHmzDXELAAAJodL87CM958.jpg" "244" height="14" />

-DSYSCONFDIR=/etc/ ##指定設定檔位置

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image022" border="0" alt="clip_image022" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQHnTVVoiAAAJBTfaX0Y672.jpg" "244" height="14" />

make &&make install #編譯安裝

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image023" border="0" alt="clip_image023" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQHqBRzxuAAAOI9BudJc426.png" "244" height="16" />

echo $?查看上命令是否執行成功

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image024" border="0" alt="clip_image024" src="http://s3.51cto.com/wyfs02/M02/86/C1/wKioL1fJQHvxg00vAAARO5yfTvQ337.png" "244" height="28" />

ls /usr/local/mysql ##驗證安裝目錄

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image026" border="0" alt="clip_image026" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQHuQrtqqAAAVe3atO5A768.jpg" "244" height="35" />

二.配置mysql

1.複製設定檔

cp /usr/src/mysql-5.5.22/support-files/my-medium.cnf /etc/my.cnf

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image028" border="0" alt="clip_image028" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQHyjlU7NAAAMYzlY4x0674.jpg" "244" height="24" />

2.添加系統服務

cp /usr/src/mysql-5.5.22/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image030" border="0" alt="clip_image030" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQH3zIixhAAAWvD2Q9Ao970.jpg" "244" height="46" />

3.最佳化PATH路徑,執行命令時方便,單引號雙引號都行

echo ‘export PATH=$PATH:/usr/local/mysql/bin‘ >>/etc/profile

source /etc/profile ##執行檔案

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image032" border="0" alt="clip_image032" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQH3hHSyzAAANxwhUCZQ811.jpg" "244" height="24" />

4.初始化mysql,建立使用者,賦權

userdel -r mysql ##如果使用者已經存在則刪除,如果不存在不管

useradd -M -s /sbin/nologin mysql

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db \

--basedir=/usr/local/mysql \

--datadir=/usr/local/mysql/data --user=mysql

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image034" border="0" alt="clip_image034" src="http://s3.51cto.com/wyfs02/M01/86/C1/wKioL1fJQH7AY35SAAAgxn7WhbE631.jpg" "244" height="80" />

5.啟動mysql,並設定為開機啟動

/etc/init.d/mysqld start

chkconfig mysqld on

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image035" border="0" alt="clip_image035" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQH-D56rpAAAqcWaweQI507.png" "244" height="39" />

6.修改密碼

mysqladmin -u root password ‘123123‘

7.登入mysql:

mysql -uroot -p123123 ##登入,也可以用-h選項指定伺服器的ip地址進行遠程登入

quit

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image037" border="0" alt="clip_image037" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKiom1fJQIChhucTAAANYueBfgc524.jpg" "244" height="18" />

650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image038" border="0" alt="clip_image038" src="http://s3.51cto.com/wyfs02/M00/86/C1/wKioL1fJQIDhJS4SAAARWyIhVxQ054.png" "141" height="41" />

安裝和配置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.