mysql-5.6.24源碼包編譯安裝

來源:互聯網
上載者:User

標籤:mysql源碼包編譯安裝

在編譯安裝mysql之前,先瞭解一下mysql具體是做啥的。

1、Mysql是一個開放源碼的小型關係型資料庫管理系統,開放者為瑞典MYSQL AB公司,目前MYSQL被廣泛地應用在Internet上的中小型網站中。由於其體積小、速度快、總體擁有成本低,尤其是開放源碼這一特點,許多種小型網站為降低網站總體擁有的成本而選擇了MYSQL作為網站資料庫。


2、安裝 Mysql

 2.1、安裝簡介

  使用者名稱:mysql

  安裝目錄:/usr/local/mysql

  資料庫目錄:/usr/local/data/mysql/data

  源碼包:mysql-5.6.24.tar.gz


 2.2、添加使用者

  useradd -s /sbin/nologin mysql


 2.3、建立所需目錄

  mkdir /usr/local/mysql

  mkdir -p /usr/local/data/mysql/data

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


 2.4、安裝編譯所需檔案或程式

  yum install gcc gcc-c++ cmake ncurses-devel bison


 2.5、mysql下載網址

 mysql源碼包下載連結http://dev.mysql.com/downloads/mysql/5.7.html

 mysql參考手冊http://dev.mysql.com/doc/


 2.6、編譯安裝

  下載mysql源碼包後,該源碼包在root的目錄下

  cd /root

  tar -zxvf mysql-5.6.24.tar.gz

  cd mysql-5.6.24

  cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/data/mysql -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  -DWITH_MYISAM_STORAGE_ENGINE=1  -DENABLE_DOWNLOADS=1

   make && make install


  2.7、編譯安裝mysql後,添加許可權

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

  mv /root/mysql-5.6.24/support-files/mysql-default.conf /etc/my.cnf

  mv /root/mysql-5.6.24/support-files/mysql.server /etc/init.d/mysqld

  chmod a+x /etc/init.d/mysqld


  2.8、設定mysql服務為開機啟動

  chkconfig --level 345 mysqld on                                                           echo "export PATH=/usr/local/mysql/bin/:$PATH" >> /etc/profile

  source /etc/profile

 2.9初始化資料庫

  /usr/local/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/data/mysql/data

  vi /etc/my.cnf(在檔案最後添加下面兩個語句)

  basedir=/usr/local/mysql

  datadir=/usr/local/data/mysql/data

3、啟動資料庫

  service mysqld start

 3.1、建立mysql管理員

  /usr/local/mysql/bin/mysqladmin -u root password ‘123456‘


-------------------------------------------------------------------------------------------


下面開始安裝


[BEGIN] 2015/12/18 22:03:34[[email protected] ~]# mkdir -p /usr/local/data/mysql/data [[email protected] ~]# useradd -s /sbin/nologin mysql [[email protected] ~]# chown -R mysql:mysql /usr/local/data/mysql/data [[email protected] ~]# yum install gcc gcc-c++ cmake ncurses-devel bison [[email protected] ~]# tar -zxvf mysql-5.6.24.tar.gz [[email protected] ~]# cd mysql-5.6.24 [[email protected] mysql-5.6.24]# mkdir /usr/local/mysql [[email protected] mysql-5.6.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  -DWITH_MYISAM_STORAGE_ENGINE=1  -DENABLE_DOWNLOADS=1 ()[[email protected] mysql-5.6.24]# make [[email protected] mysql-5.6.24]# make install [[email protected] mysql-5.6.24]# chown -R mysql:mysql /usr/local/mysql/ [[email protected] mysql-5.6.24]# mv /root/mysql-5.6.24/support-files/my-default.cnf /etc/my.cnf [[email protected] mysql-5.6.24]# mv /root/mysql-5.6.24/support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql-5.6.24]# chmod a+x /etc/init.d/mysqld[[email protected] mysql-5.6.24]# chkconfig --level 345 mysqld on[[email protected] mysql-5.6.24]# echo "export PATH=/usr/local/mysql/bin/:$PATH" >> /etc/profile[[email protected] mysql-5.6.24]# source /etc/profile[[email protected] mysql-5.6.24]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/data/mysql/data[[email protected] mysql-5.6.24]# vi /etc/my.cnf [[email protected] mysql-5.6.24]# service mysqld startStarting MySQL... SUCCESS! [[email protected] mysql-5.6.24]# /usr/local/mysql/bin/mysqladmin -u root password ‘123456‘[[email protected] mysql-5.6.24]# mysql -u root -p Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.6.24 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> exitBye


mysql-5.6.24源碼包編譯安裝

聯繫我們

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