Mysql 二進(jìn)制安裝方法
下載mysql
https://dev.mysql.com/downloads/mysql/
1.解壓包
| tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz |
2.實(shí)際生產(chǎn)環(huán)境
| mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql5.7 |
a.新增Mysql用戶組
| groupadd mysql |
b. 新增用戶
| opt]# useradd -r -g mysql mysql |
C.給mysql 目錄權(quán)限
| chown -R mysql:mysql mysql5.7 |
3. 到初始化環(huán)境的目錄
| Cd /home/usr/local/mysql5.6/mkdir datamkdir logchown -R mysql:mysql mysql5.7 |
4.初始化數(shù)據(jù)和指定安裝目錄和數(shù)據(jù)目錄
| ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql5.7/ --datadir=/usr/local/mysql5.7/data/ |
6復(fù)制啟動(dòng)文件
| cp mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld |
7.修改啟動(dòng)路徑
| vi /etc/init.d/mysqldbasedir= /usr/local/mysql5.7datadir= /usr/local/mysql5.7/data |
8.增加環(huán)境變量 (最下面添加)l
| vi /etc/profileexport MYSQL_HOME=" /usr/local/mysql5.7"export PATH="$PATH:$MYSQL_HOME/bin" |
9.刷新配置文件
| source /etc/profile |
修改配置文件
| vi /etc/my.cnf[client]port=3306[mysqld]basedir=/usr/local/mysql5.7datadir=/usr/local/mysql5.7/data#socket=/usr/local/mysql5.7/mysql.socksocket=/tmp/mysql.sockuser=mysql#skip-grant-tables# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]log-error=/usr/local/mysql5.7/log/mysqld.logpid-file=/usr/local/mysql5.7/data/mysqld.pid## include all files from the config directory#!includedir /etc/my.cnf.d |
11.添加開(kāi)啟自啟
| chkconfig --add mysqld chkconfig mysqld on |
12.啟動(dòng)mysqld
| service mysqld start netstat -anpt |
13.修改密碼(密碼初始化的時(shí)候有個(gè)密碼)