mysql源碼包安裝方法

來源:互聯網
上載者:User

標籤:工作環境   linux   mysql   local   

mysql安裝前的準備工作

環境準備:linux系統  cmake   mysql安裝包

卸載掉rpm包安裝的mysql

Yum -y remove mysql mysql-server

Rm -rf /etc/my.cnf

安裝解決依賴關係:yum -y install ncurses-devel openssl-devel bison gcc gcc-c++

mysql源碼包安裝

將源碼包上傳到/usr/local/src

Tar xzf mysql安裝包

yum -y install cmake

yum -y install bison

groupadd mysql

useradd -g mysql mysql

cd /lamp/mysql-5.5.23

cmake\

 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock  -DEXTRA_CHARSETS=all\

-DDEFULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci\

-DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1\

-DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306\

-DMYSQL_DATADIR=/usr/local/mysql/data\

-DSYSCONFDIR=/etc\

 

 

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  //安裝位置

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock   //指定socket(通訊端)檔案位置

-DEXTRA_CHARSETS=all //擴充字元支援

-DDEFULT_CHARSET=utf8 //預設字元集

-DDEFAULT_COLLATION=utf8_general_ci //預設字元校對

-DWITH_MYISAM_STORAGE_ENGINE=1 //安裝myisam儲存引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1 //安裝innodb儲存引擎

-DWITH_MEMORY_STORAGE_ENGINE=1 //安裝memory儲存引擎

-DWITH_READLINE=1 //支援readline庫

-DENABLED_LOCAL_INFILE=1 //啟用載入本機資料庫

-DMYSQL_USER=mysql //指定mysql運行使用者

-DMYSQL_TCP_PORT=3306 //指定mysql連接埠

-DMYSQL_DATADIR=/usr/local/mysql/data  //資料庫目錄,非常重要,如果再企業裡這裡不是一個普通的目錄而是一個儲存掛載點

-DSYSCONFDIR=/etc  //設定檔目錄

 

 

make && make install

 

實際生產環境中都是用指令碼方式,因為手工效率低,容易出錯,這裡的配置選項是常用的,在實際生產環境中考慮到調優,效能,安排方面來做其他對應的選項。

 

Mysql初始化過程,初次使用

cd /usr/local/mysql

chown  mysql:mysql -R /usr/local/mysql  //設定所有者為mysql

./scripts/mysql_install_db --user=mysql  --datadir=/usr/loacl/mysql/data  //建立資料庫授權表,初始化資料庫,初始化失敗的原因一般都是沒有指定字元集等,主機名稱解析問題等

 

cp support-files/my-huge.cnf /etc/my.cnf  //大型資料庫模板來初始化它的主設定檔

cp  support-files/mysql.server  /etc/init.d/mysqld   //複製開機啟動服務指令碼紅字部分是原始碼解壓後目錄位置

chmod a+x /etc/init.d/mysqld   //賦予開機自啟動指令碼執行許可權

chkconfig --add mysqld     //添加到開機自啟動

chkconfig  --list mysqld

chkconfig mysqld on

service mysqld on

service mysqld start

如果啟動失敗一般情況去看錯誤記錄檔,它會告訴你原因,一般都是主機名稱能解析,字元集沒有指定等原因

Netstat -an |grep mysql  //查看資料庫是否啟動,裡麵包含了設定檔,錯誤記錄檔位置,安裝資訊,連接埠號碼,字元集等等進程資訊

Vim /etc/profile  //編輯這個設定檔,方便以後每個人都直接使用mysql命令,不需要再加全路徑

650) this.width=650;" width="144" height="3" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" width="312" height="2" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />        650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" width="554" height="94" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />  



 //將mysql路勁加入到環境變數中  ,紅色字型是增加部分    

Source /etc/profile    //讓設定檔生效

 

 

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile  ////添加到系統內容變數便於搜尋,如果是rpm包會自動放到path變數中的

source /etc/porfile

 

登入測試:

Mysqladmin  -uroot password  ‘mysql123’  //設定mysql密碼

Mysql -u root -p mysql123登入測試:

Ctrl+l  清屏

 


本文出自 “快樂學習” 部落格,請務必保留此出處http://983865387.blog.51cto.com/9838888/1917721

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.