Centos7安装mysql5.7

1.下载安装包

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

2.创建一个mysql用户用于启动mysql

useradd mysql

3.解压

tar zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

4.创建一个软链接

#进入 usr/local/mysql 目录
ln -s mysql-5.7.24-linux-glibc2.12-x86_64 mysql

5.给予权限

chown -R mysql:mysql ./

6.初始化

#进入 usr/local/mysql 目录
./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
# 将生成的密码保存起来

7.修改配置文件

# vim /etc/my.cnf
​
#文件如下
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
explicit_defaults_for_timestamp=true
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-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/mysql/data/mysql.log
pid-file=/usr/local/mysql/data
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d                                  

8.将mysql服务添加到系统中

#进入 usr/local/mysql 目录  依次执行指令
#切换hadoop用户执行
cp support-files/mysql.server /etc/init.d/mysqld
ls -l /etc/init.d/mysqld
service  mysqld start

9.将mysql指令添加到系统指令中

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

10.初始化mysql

mysql -u root -p  
#密码为刚才记录的初始化密码
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'New12345678!';
mysql>use mysql;
#开放远程连接
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值