LAMP--1.Mysql 安裝

來源:互聯網
上載者:User

標籤:mysql   安裝   

        安裝 Mysql 有兩種選擇,一是原始碼安裝,二是安裝二進位面編譯包,為了省時選用第二種。Mysql 安裝包可以在Mysql的官網(http://dev.mysql.com/downloads/)下載,有i686和x86_64兩個版本選擇。我習慣在鏡像網站上下載,比如搜狐的開源鏡像網站(http://mirrors.sohu.com)。

        下載軟體包

         免編譯二進位包認準 glibc ,可通過 uname -i 獲得linux是多少位的。

[[email protected] ~]# cd /usr/local/src/[[email protected] ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz

        初始化

[[email protected] src]# lsmysql-5.1.73-linux-x86_64-glibc23.tar.gz[[email protected] src]# tar -zxvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz[[email protected] src]# lsmysql-5.1.73-linux-x86_64-glibc23  mysql-5.1.73-linux-x86_64-glibc23.tar.gz[[email protected] src]# mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql[[email protected] src]# useradd -s /sbin/nologin mysql            //建立 mysql 使用者[[email protected] src]# cd /usr/local/mysql[[email protected] mysql]# mkdir -p /data/mysql                 //建立 datadir,資料庫檔案會放到這裡面[[email protected] mysql]# chown -R mysql:mysql /data/mysql       //更改許可權[[email protected] mysql]# ls -dl /data/mysqldrwxr-xr-x 2 mysql mysql 4096 5月  17 14:49 /data/mysql[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

         --user 定義資料庫的所屬主, --datadir 定義資料庫安裝到哪裡。如果看到兩個“OK”說明執行成功。我遇到了一個問題:

Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory[[email protected] mysql]# yum install -y libaio

         需要使用 yum install -y libaio 解決。

         配置 mysql

         拷貝設定檔

[[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf

         拷貝啟動指令檔並修改其屬性

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql]# chmod 755 /etc/init.d/mysqld

         修改啟動指令碼

[[email protected] mysql]# vim /etc/init.d/mysqld

         需要修改的地方是 datadir=/data/mysql

[[email protected] mysql]# chkconfig --add mysqld[[email protected] mysql]# chkconfig mysqld on[[email protected] mysql]# service mysqld startStarting MySQL.. SUCCESS!

          如果啟動不了,到 /data/mysql/ 下查看錯誤記錄檔,這個日誌通常是主機名稱.err。檢查mysql是否啟動的命令為:

[[email protected] mysql]# ps aux |grep mysqldroot      4231  0.0  0.1  11304  1496 pts/1    S    16:00   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pidmysql     4346  0.6 44.7 1011204 452716 pts/1  Sl   16:00   0:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pidroot      4385  0.0  0.0 103320   904 pts/1    S+   16:04   0:00 grep mysqld



本文出自 “散宜生的學習筆記” 部落格,請務必保留此出處http://sanyisheng.blog.51cto.com/11154168/1795789

LAMP--1.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.