MySQL5.7二进制安装

MySQL5.7二进制安装

标签(空格分隔): 数据库


1.安装依赖,解压mysql二进制包到/usr/local/ ,并创建软链接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环境变量

vim /etc/profile.d/mysql.sh 
export PATH=/usr/local/mysql/bin:$PATH

3.创建mysql用户

useradd -s /sbin/nologin mysql -M

4.授权

chown -R mysql.mysql /usr/local/mysql/

5.初始化MySQL数据库

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

你可能感兴趣的:(MySQL5.7二进制安装)