一配置yum源
1 cd /mnt/cdrom
2 cd /etc/yum.repos.d/
3 vi redhat.repo
4 yum clean all
5 yum makecache
6 yum repolist
[base]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
B
a
s
e
−
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
f
a
i
l
o
v
e
r
m
e
t
h
o
d
=
p
r
i
o
r
i
t
y
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=https://mirrors.aliyun.com/centos/
releasever−Base−mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos/releasever/BaseOS/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.aliyuncs.com/centos/
basearch/os/http://mirrors.aliyuncs.com/centos/releasever/BaseOS/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
c
l
o
u
d
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.cloud.aliyuncs.com/centos/
basearch/os/http://mirrors.cloud.aliyuncs.com/centos/releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[extras]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
E
x
t
r
a
s
−
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
f
a
i
l
o
v
e
r
m
e
t
h
o
d
=
p
r
i
o
r
i
t
y
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=https://mirrors.aliyun.com/centos/
releasever−Extras−mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos/releasever/extras/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.aliyuncs.com/centos/
basearch/os/http://mirrors.aliyuncs.com/centos/releasever/extras/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
c
l
o
u
d
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.cloud.aliyuncs.com/centos/
basearch/os/http://mirrors.cloud.aliyuncs.com/centos/releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[centosplus]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
P
l
u
s
−
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
f
a
i
l
o
v
e
r
m
e
t
h
o
d
=
p
r
i
o
r
i
t
y
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=https://mirrors.aliyun.com/centos/
releasever−Plus−mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos/releasever/centosplus/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.aliyuncs.com/centos/
basearch/os/http://mirrors.aliyuncs.com/centos/releasever/centosplus/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
c
l
o
u
d
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.cloud.aliyuncs.com/centos/
basearch/os/http://mirrors.cloud.aliyuncs.com/centos/releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
P
o
w
e
r
T
o
o
l
s
−
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
f
a
i
l
o
v
e
r
m
e
t
h
o
d
=
p
r
i
o
r
i
t
y
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
releasever - PowerTools - mirrors.aliyun.com failovermethod=priority baseurl=https://mirrors.aliyun.com/centos/
releasever−PowerTools−mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos/releasever/PowerTools/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.aliyuncs.com/centos/
basearch/os/http://mirrors.aliyuncs.com/centos/releasever/PowerTools/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
c
l
o
u
d
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.cloud.aliyuncs.com/centos/
basearch/os/http://mirrors.cloud.aliyuncs.com/centos/releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
A
p
p
S
t
r
e
a
m
−
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
f
a
i
l
o
v
e
r
m
e
t
h
o
d
=
p
r
i
o
r
i
t
y
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
releasever - AppStream - mirrors.aliyun.com failovermethod=priority baseurl=https://mirrors.aliyun.com/centos/
releasever−AppStream−mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos/releasever/AppStream/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.aliyuncs.com/centos/
basearch/os/http://mirrors.aliyuncs.com/centos/releasever/AppStream/
b
a
s
e
a
r
c
h
/
o
s
/
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
c
l
o
u
d
.
a
l
i
y
u
n
c
s
.
c
o
m
/
c
e
n
t
o
s
/
basearch/os/ http://mirrors.cloud.aliyuncs.com/centos/
basearch/os/http://mirrors.cloud.aliyuncs.com/centos/releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
将MySQL数据包放入
把数据包放到主目录里面并且配置mysql数据组
[root@localhost ~] cd /usr/local/
[root@localhost local] tar xf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
[root@localhost local] ln -sv mysql-5.7.14-linux-glibc2.5-x86_64 mysql #创建软连接,方便之后操作
[root@localhost local] chown -R mysql.mysql mysql/*
初始化命令:
mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
====注意记录临时密码
解压文件并创建快捷方式
[root@localhost local] cd /usr/local/mysql
[root@localhost mysql] \cp support-files/my-default.cnf /etc/my.cnf
为mysql配置主文件
vim /etc/my.cnf
添加如下行指定mysql数据文件的存放位置:
datadir = /usr/local/mysql/data
[root@localhost mysql] cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql] chmod +x /etc/rc.d/init.d/mysqld
1
启动mysql
chkconfig --add mysqld --添加为系统服务
chkconfig mysqld on --开机自启动
systemctl start mysqld
将mysql的bin目录加入PATH环境变量,编辑/etc/profile文件
cd /etc/profile.d/
vim mysql.sh
• 添加如下内容
export PATH=$PATH:/usr/local/mysql/bin
之后
source mysql.sh启用环境变量
sudo ln -s 文件路径 快捷方式路径
sudo ln -s /usr/lib64/libncurses.so.6.1 /usr/lib64/libncurses.so.5
这样就在/usr/lib64下建立了一个libncurses.so.5的快捷方式。mysql在启动时就会寻找该libncurses.so.5依赖的快捷方式,最后实际链接到了libncurses.so.6.1依赖。
mysql -u root -p 登录,输入之前记录的随机密码
========进入MySQL终端:
修改密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘root’