(轉)linux下mysql的安裝過程

來源:互聯網
上載者:User

標籤:style   io   ar   os   使用   sp   on   檔案   資料   

最近在linux安裝了mysql,根據網上收集的資料和個人的操作過程,大概做了個整理,以便以後進行參考回顧。
1、下載mysql-5.1.36.tar.gz,並且解壓.
tar -xzvf mysql-5.1.36.tar.gz

2、添加mysql組,建立mysql使用者
groupadd mysql
useradd -g mysql mysql

3.進入解壓後的目錄下,進行編譯安裝
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --enable-assembler --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --with-plugins=all

4.make
5.make install
6.安裝完成後,mysql的安裝目錄為prefix中指定的/usr/local/mysql
7.進入安裝目錄,複製設定檔
cp support-files/my-large.cnf /etc/my.cnf

8.更新/usr/local/mysql檔案夾的所有者及使用者組
cd /usr/local/mysql/
chown -R mysql .
chgrp -R mysql .

9.配置mysql隨伺服器啟動的服務
cp /home/mysql-5.1.36/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld

10.初始化mysql
bin/mysql_install_db --user=mysql

11.啟動mysql服務
方法1:service mysqld start
方法2:/usr/local/mysql/bin/mysqld_safe --user=mysql &

12.關閉MySQL服務
/usr/local/mysql/bin/mysqladmin -u root -p  shutdown //關閉MySQL

13.查看mysql服務連接埠狀態 (3306)
  netstat -atln

14.mysql預設是沒有密碼的,設定登入mysql的新密碼
/usr/local/mysql/bin/mysqladmin -u root -password ‘xxx‘

15.登入msyql
/usr/local/mysql/bin/mysql -u root -p

16.添加mysql的使用者
登入mysql,添加mysql使用者
grant 許可權 on 資料庫名.表名 使用者@登入主機 identified by "使用者密碼";

添加testA,容許localhost登入,密碼為"123456"
添加testB,容許遠程登入,密碼為"123456"
添加testC,容許遠程登入,密碼為"123456"

GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO [email protected]"%" IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
grant select,update,insert, on *.* to  [email protected]"%" identified by "123456";

17.測試一下,在windows下使用mysql用戶端軟體指定IP地址、使用者名稱、密碼測試連接到linux下的mysql。
18.完畢。

附:
1. ./configure
--prefix=/usr/local/mysql //MySQL安裝目錄
--datadir=/mydata //資料庫存放目錄
--with-charset=utf8 //使用UTF8格式
--with-extra-charsets=complex //安裝所有的擴充字元集
--enable-thread-safe-client //啟用用戶端安全線程
--with-big-tables //啟用大表
--with-ssl //使用SSL加密
--with-embedded-server //編譯成embedded MySQL library (libmysqld.a),
--enable-local-infile //允許從本地匯入資料
--enable-assembler //彙編x86的普通操作符,可以提高效能
--with-plugins=innobase //資料庫外掛程式
--with-plugins=partition //分表功能,將一個大表分割成多個小表
2. chkconfig
參數:    --add   新增所指定的系統服務
         --del 刪除所指定的系統服務
         --level 指定該系統服務要在哪個執行等級中開啟或關閉
         --list   列出當前可從chkconfig指令管理的所有系統服務和等級代號
            on/off/reset   在指定的執行登記,開啟/關閉/重設該系統服務

chkconfig命令主要用來更新(啟動或停止)和查詢系統服務的運行級資訊。謹記chkconfig不是立即自動禁止或啟用一個服務,它只是簡單的改變了符號串連。

3.開機啟動mysql的另一種簡單方法:
/etc/rc.local裡加入/opt/mysql/bin/mysqld_safe --user=mysql &

4.直接運行mysqld程式來啟動MySQL服務的方法很少見,mysqld_safe指令碼會在啟動MySQL伺服器後繼續監控其運行情況,並在其死機時重新啟動它
用mysqld_safe指令碼來啟動MySQL伺服器的做法在BSD風格的unix系統上很常見,非BSD風格的UNIX系統中的mysql.server指令碼其實也是調用mysqld_safe指令碼去啟動MySQL伺服器的。

5.安裝過程中出現的錯誤及解決辦法
5.1啟動mysqld服務錯誤。
報錯:Starting MySQL....... ERROR! Manager of pid-file quit without updating file
解決:進入  /usr/local/mysql/var  mysql-bin.index是存放記錄檔索引的檔案,只刪除了記錄檔而沒有對日誌的索引檔案做處理顯然是不行的。
刪除mysql-bin.index檔案,再service mysqld start就可以了。
5.2 make 時系統會出現下面錯誤:
報錯:no acceptable c compiler found in path
解決:yum install gcc

(轉)linux下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.