mysql-VERSION-linux-glibc2.5-x86_64.tar.gz(官網 Generic Linux 下載)。groupadd mysql && useradd -r -g mysql -s /bin/false mysql。cd /usr/local
tar zxvf /path/to/mysql-VERSION-linux-glibc2.5-x86_64.tar.gz
ln -s mysql-VERSION-linux-glibc2.5-x86_64 mysql
cd mysql
cp support-files/my-medium.cnf /etc/my.cnf
# 編輯 /etc/my.cnf 依需求調整:
# [mysqld]
# datadir=/usr/local/mysql/data
# socket=/tmp/mysql.sock
# port=3306
# innodb_buffer_pool_size=1G
# ...
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
bin/mysqld_safe --user=mysql &
# 驗證
bin/mysqladmin -u root version
bin/mysql -u root -e "SHOW DATABASES;"
bin/mysqladmin -u root password 'new_strong_password'
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld start
# iptables
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save
# 或 firewalld
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload
netstat -tlnp | grep 3306
mysql -h 127.0.0.1 -u root -p
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
cd /usr/local
tar zxvf mysql-VERSION.tar.gz
ln -s mysql-VERSION mysql
cd mysql
cp support-files/my-medium.cnf /etc/my.cnf
chown -R mysql . ; chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root . ; chown -R mysql data
bin/mysqld_safe --user=mysql &
bin/mysqladmin -u root password 'pass'
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld ; chkconfig --level 345 mysqld on
service mysqld start
二進制免安裝版部署簡單、無編譯依賴、適合快速交付。關鍵點:mysql 用戶權限、mysql_install_db 初始化、my.cnf 配置、服務註冊與防火牆。生產環境請依硬體資源調整 InnoDB 參數、啟用慢查詢日誌、配置主從複寫與備份策略。