mysql伺服器安裝與配置

來源:互聯網
上載者:User

ps:本文章轉載自http://blog.csdn.net/lyjinger/article/details/1648845

lyjinger軟體使用之:mysql伺服器安裝與配置

說明:說說自己安裝和配置mysql伺服器的一點心得體會。mysql版本:Ver 5.0.41,平台:linux-i386

一、mysql安裝步驟:
1、解壓和安裝(分原始碼包src安裝和二進位包bin安裝來討論)
  其實mysql的安裝比較簡單,基本照著它裡面的INSTALL來做就行了。
對於原始碼包,其步驟如下:
  tar -zxvf mysql-5.0.41.tar.gz
  ./configure --prefix=/usr/local/mysql /
          --with-extra-charsets=gbk /
          --with-charset=gbk
  make
  make install
對於二進位包,其步驟如下:
  cd /usr/local
  tar -zxvf mysql-5.0.41-linux-i686.tar.gz
  ln -s mysql-5.0.41-linux-i686 mysql

2、添加資料庫使用者和組
  groupadd mysql
  useradd -g mysql mysql

3、安裝資料庫
  cd /usr/local/mysql
  ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
  cp support-files/my-medium.cnf /etc/my.cnf
  bin/mysql_install_db --user=mysql
  chown -R root .
src包執行:
  chown -R mysql var
bin包執行:
  chown -R mysql data
  chgrp -R mysql .

4、測試安裝是否成功
  bin/mysqld_safe --user=mysql &
  mysql -u root -p (註:root使用者初始密碼為空白,Enter password:時直接斷行符號即可。)
如果進入mysql提示符則表明安裝成功,否則安裝失敗,請檢查前述安裝步驟。

二、mysql配置(個人做法,僅供參考):
1、配置mysql自啟動服務
  cp support-files/mysql.server /etc/init.d
  ln -s /etc/init.d/mysql.server /etc/rc3.d/S99mysql
  ln -s /etc/init.d/mysql.server /etc/rc0.d/K01mysql
  reboot 來測試自啟動服務是否成功

2、資料庫使用者、密碼及存取權限設定:
  mysql -u root -p
  use mysql;
刪除匿名使用者:
  DELETE FROM user where User='';
設定root使用者密碼:
  SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('[newpassword]');
  SET PASSWORD FOR 'root'@'localhost' = PASSWORD('[newpassword]');
  SET PASSWORD FOR 'root'@'hostname' = PASSWORD('[newpassword]');
  FLUSH PRIVILEGES;

設定遠端存取:
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '[newpassword]' WITH GRANT OPTION;

相關文章

聯繫我們

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