二:linux之mysql二进制安装

linux之mysql二进制安装

1 下载 https://dev.mysql.com/downloads/mysql/5.7.html

yum install libaio

yum install  libncurses.*


2 解压

tar -zvxf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.7.30-linux-glibc2.12-x86_64 mysql3306

3添加MySQL用户及用户组

groupadd mysql

useradd -g mysql -d /usr/local/mysql/mysql3306/ -s /sbin/nologin -M mysql

当删除时如下命令

groupdel -Rf mysql

userdel -rf mysql

4 创建软连接

ln -s 源目录 目标文件

ln -s /usr/local/mysql/mysql3306 mysql

chown -R mysql:mysql mysql 更改宿主

当删除时候用 rm -rf ./mysql

5 导入配置文件 在 /etc下创建  mkdir -p my.cnf放入如下配置

[mysqld]

user=root

gtid_mode=1

basedir=/usr/local/mysql/mysql3306

datadir=/usr/local/mysql/configuration/data

tmpdir=/usr/local/mysql/configuration/tmp

socket=/usr/local/mysql/configuration/tmp/mysql.sock

slave_load_tmpdir=/usr/local/mysql/configuration/tmp

secure_file_priv=/usr/local/mysql/configuration/tmp

log-error=/usr/local/mysql/configuration/log/mysqld.log

pid-file=/usr/local/mysql/configuration/run/mysqld.pid

symbolic-links=0

explicit_defaults_for_timestamp=true

lc_messages=en_US

lc_messages_dir=/usr/local/mysql/mysql3306/share/english

language=/usr/local/mysql/mysql3306/share/english

6创建mysqld相关目录

mkdir -p /usr/local/mysql/configuration/{run,log,data,tmp}

chown -R mysql:mysql /usr/local/mysql/  更改宿主

7初始化mysql 配置文件

cd /usr/local/mysql/mysql3306/bin

./mysqld --defaults-file=/etc/my.cnf --initialize

8 启动mysql

cd /usr/local/mysql/mysql3306

cp support-files/mysql.server /etc/init.d/mysql

chkconfig --add mysql

/etc/init.d/mysql start 启动

/etc/init.d/mysql stop 停止

/etc/init.d/mysql status 状态

9获取初始化密码

cat /usr/local/mysql/configuration/log/mysqld.log


10 修改密码

cd /usr/local/mysql/mysql3306/bin

./mysql_secure_installation --socket=/usr/local/mysql/configuration/tmp/mysql.sock

11 设置 登录软连接

ln -s /usr/local/mysql/mysql3306/bin/mysql /usr/bin

12 登录mysql

mysql -uroot -pYumeko213@ --socket=/usr/local/mysql/configuration/tmp/mysql.sock

13 自启动

systemctl enable mysql 自启动

你可能感兴趣的:(二:linux之mysql二进制安装)