Mysql 的源碼包安裝

來源:互聯網
上載者:User

標籤:伺服器   mysql   使用者   

msyql 伺服器:mysql-5.5.30.tar.gz

安裝前,如果不存在 mysql 使用者,則建立之

[[email protected] ~]#  useradd mysql
[[email protected] ~]# vim /etc/passwd  #不讓 mysql 使用者登入系統

改成: mysql:x:501:501::/home/mysql:/sbin/nologin

解壓安裝

[[email protected] ~]#  tar zxvf mysql-5.5.30.tar.gz -C /usr/local/src/

[[email protected] ~]#  cd /usr/local/src/mysql-5.5.30/

編譯,安裝:

Mysql 5.5.15 使用了新的 cmake 編譯方式,所以先安裝 cmake

[[email protected] mysql-5.5.30]# yum install -y cmake

開始編譯:

[[email protected] mysql-5.5.30]# mkdir /server/

[[email protected] mysql-5.5.30]# cmake  -DCMAKE_INSTALL_PREFIX=/server/mysql-5.5 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EXTRA_CHARSETS=all  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1  -DMYSQL_DATADIR=/server/mysql/data -DMYSQL_USER=mysql

安裝:

[[email protected] mysql-5.5.30]#  make -j 4

[[email protected] mysql-5.5.30]# make install

配置 mysql 運行環境:

[[email protected] mysql-5.5.30]# chown -R mysql:mysql /server/mysql-5.5/

#修改mysql安裝目錄許可權, 允許mysql使用者對mysql

資料庫檔案夾讀寫。

複製 mysql 設定檔

[root[email protected] mysql-5.5.30]# cp  /usr/local/src/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf

設定 mysqld5.5 服務開機啟動:

[[email protected] mysql-5.5.30]# cp /usr/local/src/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld5.5

複製 mysql 開機開機檔案,以後可以使用 service 命令來啟動和關閉 mysql

[[email protected] mysql-5.5.30]# chmod +x /etc/init.d/mysqld5.5
[[email protected] mysql-5.5.30]# vim /etc/init.d/mysqld5.5

basedir=

datadir=

修改成:

basedir=/server/mysql-5.5

datadir=/server/mysql-5.5/data

加入開機啟動項:

[[email protected] ~]# chkconfig mysqld5.5 on
[[email protected] ~]# chkconfig --list mysqld5.5
mysqld5.5      0:關閉1:關閉2:啟用3:啟用4:啟用5:啟用6:關閉

初始化 mysql 資料庫:

[[email protected] ~]# cd /usr/local/src/mysql-5.5.30/scripts
[[email protected] scripts]# chmod +x mysql_install_db

[[email protected] scripts]# ./mysql_install_db  --defaults-file=/etc/my.cnf --basedir=/server/mysql-5.5 --datadir=/server/mysql-5.5/data --user=mysql

開機 mysql

[[email protected] scripts]# /etc/init.d/mysqld5.5 start

測試登入:

設定 mysql root 密碼

[[email protected] ~]# mysqladmin -uroot password ‘123456‘

[[email protected] ~]# mysql -u root -p123456


本文出自 “linux營運” 部落格,請務必保留此出處http://linuxshare.blog.51cto.com/8944591/1671433

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.