centos 下編譯安裝mysql5.1與mysql5.5

來源:互聯網
上載者:User

標籤:os   io   檔案   資料   for   art   ar   問題   

mysql5.1.60編譯安裝
1、tar -zxvf mysql*
2、./configure 之前要make clean
./configure --prefix=/home/shk/mysql-5.1.60 \
--enable-local-infile \
--with-unix-socket-path=/home/shk/mysql-5.1.60/var/mysql.sock \
--with-tcp-port=5506 \
--enable-thread-safe-client \
--with-mysqld-user=root \
--with-extra-charsets=gb2312,big5,gbk,binary,ascii,latin1 \
--with-charset=utf8 \
--with-federated-storage-engine \
--with-partition

注釋:在執行“make clean” 失敗時,提示錯誤checking for termcap functions library... configure: error: Nocurses/termcap library found 。
則在執行./configure命令,執行命令代碼為:
./configure--prefix=/usr/share/mysql/ -with-charset=utf8 -with-extra-charsets=all –with-named-curses-libs=/usr/lib/libncursesw.so.5(最後一段命令可以省略)

出現錯誤:No curses/termcap library found 或者seethe install manual chapter in the reference
yum –y install gcc yum install ncurses-devel
在安裝gcc時,出錯libstdc++-devel*安裝不上,則手動下一個libstdc++-devel*.rpm封裝上,
在用rpm安裝libstdc++-devel*.rpm時報錯:error: Failed dependencies,
則用命令:rpm -ivh libstdc++*.rpm --nodeps --force
3、make
如果報錯,則減少configure的項
4、make install
5、建立MYSQL的開機檔案
#chown -R root:mysql /usr/local/mysql
#chown -R mysql:mysql /usr/local/mysql/data
#chown -R mysql:mysql /usr/local/mysql/lib

#cd /usr/local/mysql/bin/
#./mysql_install_db --user=mysql
#cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
#cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
6、啟動MySQL
#/usr/local/mysql/share/mysql/mysql.server start
7、下載編譯安裝的mysql
在源碼檔案中執行:make uninstall
mysql5.5.31編譯安裝
1、下載安裝編譯MySQL源碼需要的庫
sudo apt-get install build-essential libncurses5-dev cmake
2、添加mysql使用者組和使用者
groupadd mysql
useradd -g mysql mysql
3、建立MySQL軟體安裝目錄和資料存放目錄
mkdir -p /opt/mysql #MySQL安裝目錄
chown -R mysql:mysql /opt/mysql
mkdir -p /data/mysql #MySQL資料存放目錄
mkdir -p /data/mysql/data #存放資料
mkdir -p /data/mysql/log #存放日誌
mkdir -p /data/mysql/tmp #存放臨時檔案
chown -R mysql:mysql /data/mysql

4、cmake編譯安裝MySQL
tar -zxvf mysql-5.6.13.tar.gz
cd mysql-5.6.13
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/opt/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
make
make install
參數說明:
-DCMAKE_INSTALL_PREFIX=/opt/mysql //指定安裝目錄
-DINSTALL_DATADIR=/data/mysql //指定資料存放目錄
-DSYSCONFDIR=/opt/mysql //指定設定檔目錄(本例的設定檔為/opt/mysql/my.cnf)
-DDEFAULT_CHARSET=utf8 //指定字元集
-DDEFAULT_COLLATION=utf8_general_ci //指定校正字元
-DEXTRA_CHARSETS=all //安裝所有擴充字元集
-DENABLED_LOCAL_INFILE=1 //允許從本地匯入資料
上述步驟執行成功後,MySQL軟體已成功安裝至/opt/mysql目錄下。

5、編輯設定檔my.cnf
[client]
port= 3306
socket = /opt/mysql/run/mysql.sock

[mysql]

[mysqld_safe]
pid-file = /opt/mysql/run/mysqld.pid
socket = /opt/mysql/run/mysql.sock
nice= 0

[mysqld]

#### Baes dir ####
basedir = /opt/mysql
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
socket = /opt/mysql/run/mysql.sock
user=mysql
#### Base configure info ####
port = 3306

skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address= 127.0.0.1
#
# * Fine Tuning
#
key_buffer= 16M
max_allowed_packet= 16M
thread_stack= 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit= 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
log-error = /data/mysql/log/alert.log
slow_query_log_file= /data/mysql/log/slow.log
# Here you can see queries with especially long duration
#log_slow_queries= /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes

#### Binary log && Relay log ####
#binlog_format=‘MIXED‘
log-bin = /data/mysql/log/mysql-bin
log-slave-updates = 1
relay-log = /data/mysql/log/mysqld-relay-bin
relay-log-index = /data/mysql/log/mysqld-relay-bin.index
master-info-file = /data/mysql/log/master.info
relay-log-info-file = /data/mysql/log/relay-log.info
max_binlog_size = 100M

[mysqldump]
quick
quote-names
max_allowed_packet= 16M

[mysql]
#no-auto-rehash# faster start of mysql but no tab completition

[isamchk]
key_buffer= 16M
6、建立資料庫
/opt/mysql/scripts/mysql_install_db --user=mysql
上述建庫語句將根據my.cnf裡設定的資料檔案目錄和記錄檔目錄,產生相應的資料檔案和記錄檔,並建立系統資料庫(如mysql,test,information_schema,performance_schema)
7、啟動MySQL
/opt/mysql/support-files/mysql.server start
啟動成功後,就可以以root使用者登入(預設的root使用者沒有密碼)
/opt/mysql/bin/mysql -u root
查看是否可以登入
8、設定root密碼
mysqladmin -u root password ‘123456a?‘
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456a?‘ WITH GRANT OPTION;

9、最後,把MySQL加入系統啟動項和開機啟動
在/etc/profile 檔案中增加
export PATH=$PATH:/opt/mysql/bin
cp ./support-files/mysql.server /etc/init.d/mysqld #把Mysql加入系統啟動
chmod 755 /etc/init.d/mysqld #增加執行許可權
update-rc.d -f mysqld defaults #加入開機啟動

錯誤與解決:
1、錯誤資訊:The server quit without updating PID file
解決:配置資訊可能太多,適當的刪除參數
2、注意檔案許可權問題

相關文章

聯繫我們

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