CentOS7 MySQL5.7.22 安裝步驟及問題總結

CentOS7 MySQL5.7.22 安裝步驟及問題總結

自行下載安裝包 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz,將安裝包拷貝到 /opt 下;
執行命令(如下):
cd /opt
tar zxf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.22-linux-glibc2.12-x86_64 mysql
cd /opt/mysql
cp share/english/errmsg.sys /opt/mysql/share/
mkdir -p /opt/data/mysql/data
配置 /etc/my.cnf 文件
./bin/mysqld --initialize --user=root --basedir=/opt/mysql/ --datadir=/opt/data/mysql/data
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
service mysqld start
如果在這裏出錯:
Starting MySQL.Logging to ‘/opt/data/mysql/data/hostname.err’.
ERROR! The server quit without updating PID file (/opt/data/mysql/data/hostname.pid).
刪除 /opt/data/mysql/data 下的文件,再執行初始化:
rm -rf /opt/data/mysql/data/*
./bin/mysqld --initialize --user=root --basedir=/opt/mysql/ --datadir=/opt/data/mysql/data > …/setup.out
service mysqld start

Starting MySQL.Logging to ‘/opt/wolfengi/data/mysql/data/hostname.err’.
SUCCESS!

my.cnf 文件配置
[mysqld]
skip-name-resolve
#設置3306端口
port = 3306
socket=/opt/wolfengi/data/mysql/mysql.sock
#設置mysql的安裝目錄
basedir=/opt/wolfengi/mysql
#設置mysql數據庫的數據的存放目錄
datadir=/opt/wolfengi/data/mysql/data
#允許最大連接數
max_connections=200
#服務端使用的字符集默認爲8比特編碼的latin1字符集
character-set-server=utf8
#創建新表時將使用的默認存儲引擎
default-storage-engine=INNODB
#忽略大小寫設置
lower_case_table_names=1
max_allowed_packet=16M
#用戶啓動mysql的用戶
user=root

問題總結

MySQL5.7 版本配置my.cnf文件,一定要有:user=$USER
如果沒有這個配置項,會導致 mysql 起不來,出現如下錯誤:
Starting MySQL.Logging to ‘/opt/data/mysql/data/hostname.err’.
ERROR! The server quit without updating PID file (/opt/data/mysql/data/hostname.pid).
MySQL5.6 版本不存在這個問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章