標籤:mysql安裝 lamp
採用源碼安裝,可以根據實際生產環境加入一些參數,提升mysql效能
mysql官網https://www.mysql.com/
本文採用5.1版本盡心安裝說明,後面版本如5.5安裝方法會有些不一樣,在公司的一些生產環境中也有用到
5.1版本mysql。
下載mysql源碼
解壓tar zxf mysql-5.1.72.tar.gz
cd ?mysql-5.1.72
配置
./configure --prefix=/usr/local/mysql \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--localstatedir=/usr/local/mysql/data\ ? ?
--enable-assemble \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--with-pthread \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
[[email protected] mysql-5.1.72]# ./configure --help ?查看具體的配置參數
make&&make install
這裡採用開發測試模板
/bin/cp support-files/my-small.cnf ? /etc/my.cnf
建立資料庫檔案
mkdir -p /usr/local/mysql/data
chown -R mysql /usr/local/mysql授權mysql使用者可以訪問mysql目錄
/usr/local/mysql/bin/mysql_install_db --user=mysql安裝mysql資料庫檔案
安裝完後會有一些相關說明,如如何啟動等等。
安裝安裝說明方法啟動mysql
/usr/local/mysql/bin/mysqld_safe/usr/local/mysql/bin/mysqld_safe & ? ?&表示後台運行
為了更方便的啟動mysql,可以將mysql加到全域變數中
將mysql加到全域變數中echo ‘export PATH=$PATH:/usr/local/mysql/bin‘>>/etc/profile
source /etc/profile
執行mysql進入資料庫
[[email protected] mysql-5.1.72]# mysql
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.72 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
配置/etc/init.d/mysqld啟動mysql
cp support-files/mysql.server ?/etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld 授權,
將mysql服務加到開機啟動?
[[email protected] mysql-5.1.72]# chkconfig --add mysqld
[[email protected] mysql-5.1.72]# chkconfig mysqld ?on
mysql進入資料庫
設定密碼set password for [email protected]=PASSWORD(‘123456‘);
後續採用mysql -uroot -p形式進入mysql資料庫
Linux WEB伺服器搭建-MySql篇