CentOS安装离线版MySQL5.7

一颗蔬菜 2019-09-21 PM 74℃ 0条
解压
tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
sudo mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql
创建data目录
sudo mkdir data
创建配置文件
cd /opt/mysql
vi my.cnf

my.cnf

[mysqld]
basedir = /opt/mysql
datadir = /opt/mysql/data
socket = /tmp/mysql.sock
lower_case_table_names = 1
user = root
character-set-server = utf8
symbolic-links = 0
[client]
default-character-set = utf8
[mysql-safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sudo cp /opt/mysql/my.cnf /etc/
关闭selinux
sudo vi /etc/selinux/config

将SELINUX=enforcing改为SELINUX=disabled,保存后退出
初始化数据库
/opt/mysql/bin/mysqld --initialize-insecure --basedir=/opt/mysql  --datadir=/opt/mysql/data --user=root
将mysql加入服务
 cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql 
设置mysql开机启动
chkconfig mysql on    
启动mysql服务
service mysql start    
修改环境变量
export MYSQL_HOME=/opt/mysql
export PATH=$PATH:$MYSQL_HOME/bin
无密登陆mysql,设置密码
mysql -u root -p
set password=password('spark666')
创建Hive数据库
create database hive default charset utf8; 
赋予权限
 grant all privileges on *.* to 'root'@'%' identified by 'spark666';    
刷新权限
flush privileges;
退出
exit
重新登陆查看数据库
mysql -u root -p
show databases;
标签: none

非特殊说明,本博所有文章均为博主原创。