mysql單一實例的安裝和簡單配置(5.1.*版本)

來源:互聯網
上載者:User

標籤:軟體包   mysql單一實例的安裝和簡單配置   


1.建立mysql帳號
useradd -M -s /sbin/nologin -u 49 mysql

執行過程:

[[email protected] ~]# useradd -M -s /sbin/nologin -u 49mysql

[[email protected] ~]# cat /etc/passwd | grep mysql

mysql:x:49:500::/home/mysql:/sbin/nologin

參數說明:

-M 不建立mysql家目錄

-s 指定mysql登入的shell環境,nologin表示不登入shell

-u 指定mysql使用者的uid

2. 檢查系統是否存在mysql,存在則卸載。此外還要安裝ncurses ncurses-devel
[[email protected] ~]# rpm -q mysqldpackage mysqld is not installed[[email protected] ~]# yum install ncurses ncurses-devel -y
3.下載mysql軟體包,編譯安裝
cd /usr/src/     wget http://down1.chinaunix.net/distfiles/mysql-5.1.56.tar.gztar zxf mysql-5.1.56.tar.gzcd mysql-5.1.56./configure--prefix=/usr/local/mysql-5.1.56 --with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock  --with-charset=utf8--with-collation=utf8_general_ci   --with-extra-charsets=gbk,gb2312--localstatedir=/usr/local/mysql-5.1.56/data --enable-assembler--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-thread-safe-client--with-mysqld-user=mysql --with-big-table --without-debug  --with-pthreadmake && make install

執行過程:

[[email protected] src]# tar zxf  mysql-5.1.56.tar.gz

[[email protected] src]# cd mysql-5.1.56

[[email protected] mysql-5.1.56]# ./configure --prefix=/usr/local/mysql-5.1.56--with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock  --with-charset=utf8--with-collation=utf8_general_ci   --with-extra-charsets=gbk,gb2312--localstatedir=/usr/local/mysql-5.1.56/data --enable-assembler --with-mysqld-ldflags=-all-static  --with-client-ldflags=-all-static--enable-thread-safe-client --with-mysqld-user=mysql --with-big-table--without-debug  --with-pthread

[[email protected] mysql-5.1.56]# make && makeinstall

參數解釋:

     ./configure--prefix=/usr/local/mysql-5.1.56       #指定安裝路徑

     --with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock  \ #指定mysql.sock位置

      --with-charset=utf8          #指定mysql預設的字元集

       --with-collation=utf8_general_ci     

       --with-extra-charsets=gbk,gb2312    #指定mysql可擴充的字元集

      --localstatedir=/usr/local/mysql-5.1.56/data     #指定mysql 資料庫檔案存放的位置

     --enable-assembler     #允許使用彙編模式(最佳化效能)

      --with-mysqld-ldflags=-all-static   #伺服器使用靜態庫(最佳化效能)

      --with-client-ldflags=-all-static   #用戶端使用靜態庫(最佳化效能)

      --enable-thread-safe-client      #以線程方式編譯mysql

      --with-mysqld-user=mysql        #指定mysql啟動並執行使用者

     --with-big-tables     #支援大表格式

     --without-debug     #使用非debug模式

     --with-pthread        #強制使用pthread線程式庫編譯

      配置完成之後,沒有error提示,出現thanke you for choosemysql即可執行make 編譯安裝,最後make install 安裝到系統

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/58/1E/wKiom1SpL4XxrGJVAADc8mtEwPo541.jpg" title="1.png" alt="wKiom1SpL4XxrGJVAADc8mtEwPo541.jpg" />

4.配置mysql

4.1產生mysql 的主設定檔 my.cnf

[[email protected] mysql-5.1.56]# cp -f/usr/src/mysql-5.1.56/support-files/my-medium.cnf /etc/my.cnfcp: overwrite `/etc/my.cnf‘? y           #覆蓋掉原來的即可

4.2產生mysql的開機檔案,便於管理

[[email protected] mysql-5.1.56]# cp -f/usr/src/mysql-5.1.56/support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql-5.1.56]# chmod a+x/etc/init.d/mysqld[[email protected] mysql-5.1.56]# chkconfig --add mysqld[[email protected] mysql-5.1.56]# chkconfig mysqld on

4.3連結mysql執行路徑

[[email protected] ~]# ln -sf /usr/local/mysql-5.1.56/bin/*/usr/local/bin/[[email protected] ~]# ln -sf/usr/local/mysql-5.1.56/lib/mysql/* /usr/lib[[email protected] ~]# ln -sf/usr/local/mysql-5.1.56/include/mysql/* /usr/include/[[email protected] ~]# ln -sf /usr/local/mysql-5.1.56//usr/local/mysql

4.5初始化資料庫

[[email protected] ~]# cd /usr/local/mysql/bin/[[email protected] bin]# ./mysql_install_db --user=mysql--basedir=/usr/local/mysql-5.1.56/ --datadir=/usr/local/mysql-5.1.56/data當出現兩個OK時,表示初始化成功

  4.6.設定許可權

[[email protected] bin]# chown -R root:mysql/usr/local/mysql-5.1.56/[[email protected] bin]# chown -R mysql/usr/local/mysql-5.1.56/data/

  4.7.啟動mysql

[[email protected] bin]# service mysqld start   Starting MySQL SUCCESS! [[email protected] bin]# netstat -anput | grep mysqltcp       0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      42386/mysqld


本文出自 “Study-Everyday” 部落格,請務必保留此出處http://studys.blog.51cto.com/9736817/1599107

mysql單一實例的安裝和簡單配置(5.1.*版本)

聯繫我們

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