MySQL二進位檔案規範安裝

來源:互聯網
上載者:User

MySQL二進位檔案規範安裝

示範環境介紹

作業系統:CentOS 6.7  (64位)

二進位包:mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

MySQL :http://dev.mysql.com/downloads/

1、下載MySQL

# mkdir /root/mysql

# cd /root/mysql

# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

2、解壓

# cd /opt/
# mkdir mysql
# cd mysql
# tar zxvf /root/mysql/mysql-5.6.30....
# ln -s /opt/mysql/mysql-5.6.30-linux-glibc2.5-x86_64 /usr/local/mysql
# cd /usr/local/mysql

3、建立使用者

# groupadd mysql
# useradd -g mysql -M -s /sbin/nologin mysql

4、環境變數

# vim /etc/profile
  PATH=$PATH:/usr/local/mysql
# source /etc/profile

5、建立必須的目錄
/data/mysql/mysql3376/
  data  資料目錄
   tmp 臨時檔案
   logs 二進位日誌目錄
# mkdir -p /data/mysql/mysql3376/{data,tmp,logs}


6、許可權
# chown -R mysql:mysql /data/mysql/mysql3376/
# chown -R mysql:mysql /opt/mysql
# chown -R mysql:mysql /usr/local/mysql

7. 建立一個設定檔

[client]
port = 3376
socket = /tmp/mysql3376.sock

# The MySQL server
[mysqld]
# Basic
port = 3376
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3376/data
tmpdir = /data/mysql/mysql3376/tmp
socket = /tmp/mysql3376.sock

log-bin = /data/mysql/mysql3376/logs/mysql-bin
log-error = error.log
slow-query-log-file = slow.log
skip-external-locking
skip-name-resolve
log-slave-updates

8、初始化

# cd /usr/local/mysql
# ./scripts/mysql_install_db --defaults-file=/etc/my.cnf

  看到兩次ok

9. 啟動 & 關閉

啟動:
# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &

  或者

# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf &

關閉:
# /usr/local/mysql/bin/mysqladmin -S /tmp/mysql3376.sock shutdown


10、 安全強化

# delete from mysql.user where user!='root' or host!='localhost';
# truncate table mysql.db;
# drop database test;
# flush privileges;

怎麼確認mysql是啟動起來的?

A 查看進程是否存在
# ps axu |grep mysqld
 B 查看連接埠是不是監聽正確
# ss -lnpt |grep mysqld

C 看看錯誤記錄檔有無異常

本文永久更新連結地址:

相關文章

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.