一、下载安装包 安装包下载 https://downloads.mysql.com/archives/community/ 选择自己要下载的版本下载 二、上传到Linux机器进行解压 tar -zxvf mysql-5.7.39-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.3
一、下载安装包
安装包下载 https://downloads.mysql.com/archives/community/
选择自己要下载的版本下载
二、上传到Linux机器进行解压
tar -zxvf mysql-5.7.39-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.39-linux-glibc2.12-x86_64 mysql-5.7.39三、添加系统mysql组和MySQL用户
cat /etc/group | grep mysqlmysql:x:27:cat /etc/passwd | grep mysqlmysql:x:27:27:MySQL Server:/var/lib/mysql:/sbin/nologin如无,执行添加命令:groupadd mysqluseradd -r -g mysql mysql四、安装数据库
1.在解压的MySQL目录下创建data目录
mkdir data2.将/usr/local/mysql/mysql-5.7的所有者及所属组改为mysql
chown -R mysql.mysql /usr/local/mysql/mysql-5.73.在/usr/local/mysql/mysql-5.7/support-files目录下创建my_default.cnf
cd support-files/vim my_default.cnf并且写入文件,保存覆盖
[mysqld]sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLESbasedir = /usr/local/mysql/mysql-5.7datadir = /usr/local/mysql/mysql-5.7/dataport = 3306socket = /tmp/mysql.sockcharacter-set-server=utf8log-error = /usr/local/mysql/mysql-5.7/data/mysqld.logpid-file = /usr/local/mysql/mysql-5.7/data/mysqld.pid4.初始化 mysqld
cd /usr/local/mysql/mysql-5.7/./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql-5.7/ --datadir=/usr/local/mysql/mysql-5.7.39/data/5.初始化成功,在日志中查看默认密码
cd /usr/local/mysql/mysql-5.7/data/6.把启动脚本放到开机初始化目录
cp support-files/mysql.server /etc/init.d/mysql7.登录mysql,修改密码,添加远程访问权限
见文章:
https://blog.51cto.com/u_15227402/5907011
8.重启mysql生效
service mysql stop 关闭mysql
service mysql start 开启mysql
service mysql restart 重启mysql