码迷,mamicode.com
首页 > 数据库 > 详细

[MySql]VMware虚拟机CentOS7.4 LInux上安装MySql5.7,tar包安装

时间:2020-06-13 17:29:58      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:sub   命令   chgrp   cte   vim   one   tmp   访问   虚拟机   

Centos7.4 Mysql5.7.28 tar包解压安装
下载MySQL的linux安装包:
mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
利用xftp将mysql5.7的linux版本的压缩包上传到linux,上传路径:/usr/data/sftp/mysftp/upload
#在/usr/local下创建mysql文件夹
mkdir /usr/local/mysql
#复制压缩包到/usr/local/mysql
cp mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz  /usr/local/mysql
#解压
tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
#删除压缩包
rm -rf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
#将mysql-5.7.28-linux-glibc2.12-x86_64文件夹的名字修改为mysql-5.7.28
mv /usr/local/mysql/mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql/mysql-5.7.28
mkdir /usr/local/mysql/mysql-5.7.28/data
mkdir /usr/local/mysql/mysql-5.7.28/log
touch /usr/local/mysql/mysql-5.7.28/log/mysqld.log
#更改文件归属为mysql
chown -R mysql /usr/local/mysql/mysql-5.7.28/
chgrp -R mysql /usr/local/mysql/mysql-5.7.28/
#安装libaio(如果没有安装就执行下一条命令会报错)
yum install  libaio-devel.x86_64
#初始化数据库,安装数据库
./bin/mysqld --user=mysql --basedir=/usr/local/mysql/mysql-5.7.28/ --datadir=/usr/local/mysql/mysql-5.7.28/data --initialize
yum install vim
#新建配置文件my.cnf,启动
vim /etc/my.cnf
#复制以下内容  注意该文件 _和-是一样的作用(下横线和中横线) 但是mysql中的变量是下横线 如show variables like "%relay_log%";
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character_set_server=utf8
init_connect=‘SET NAMES utf8‘
basedir=/u01/mysql-5.7.25
datadir=/u01/mysql-5.7.25/data
socket=/tmp/mysql.sock
#log-error=/var/log/mysqld.log  如果设置的绝对路径 需要给权限 如果直接写名字就默认在数据目录下
#pid-file=/var/log/mysqld.log
log-error=mysqld.log
pid-file=mysqld.pid
lower_case_table_names = 1 #表名不区分大小写
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=100
default-time_zone = ‘+8:00‘
#启动mysql
/usr/local/mysql/mysql-5.7.28/support-files/mysql.server start
#或者直接服务启动
cp /usr/local/mysql/mysql-5.7.28/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
#添加环境变量  
vi /etc/profile
#添加如下内容:
# MYSQL
export MYSQL_HOME="/usr/local/mysql/mysql-5.7.28/"
export PATH="$PATH:$MYSQL_HOME/bin"
#使环境变量生效
source /etc/profile
./bin/mysqld --user=mysql --basedir=/usr/local/mysql/mysql-5.7.28/ --datadir=/usr/local/mysql/mysql-5.7.28/data/ --initialize
#查看初始密码
cat /var/log/mysqld.log或者cat /usr/local/mysql/mysql-5.7.28/data/mysqld.log
#修改密码
/usr/local/mysql/mysql-5.7.28/bin/mysql -uroot -p
#输入你在上面看到的初始密码
#修改密码并设置root可访问   my.cnf添加skip-grant-tables免密码登录
set password=password(‘123456‘);
UPDATE `mysql`.`user` SET `Host` = ‘%‘,  `User` = ‘root‘  WHERE (`Host` = ‘localhost‘) AND (`User` = ‘root‘);
flush privileges;
#创建服务并设置开启的
cp /usr/local/mysql/mysql-5.7.28/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
 
 
 

[MySql]VMware虚拟机CentOS7.4 LInux上安装MySql5.7,tar包安装

标签:sub   命令   chgrp   cte   vim   one   tmp   访问   虚拟机   

原文地址:https://www.cnblogs.com/merrysr/p/13118021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!