MySQL5.7二進制安裝
標(biāo)簽(空格分隔): 數(shù)據(jù)庫
1.安裝依賴,解壓mysql二進制包到/usr/local/ ,并創(chuàng)建軟鏈接mysql
yum install bison-devel ncurses-devel libaio-devel
wget https://downloads.mysql.com/archives/get/file/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
2.添加mysql環(huán)境變量
vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
3.創(chuàng)建mysql用戶
useradd -s /sbin/nologin mysql -M
4.授權(quán)
chown -R mysql.mysql /usr/local/mysql/
5.初始化MySQL數(shù)據(jù)庫
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
6.systemd管理MySQL
vim /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
7.重新加載systemd
systemctl daemon-reload
8.配置文件
vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
user=mysql
server_id=5106
log-error=/usr/local/mysql/data/error.log
skip_name_resolve
port=3306
9.啟動MySQL
systemctl start mysqld.service