centos 7.2 mysql 安装

前端之家收集整理的这篇文章主要介绍了centos 7.2 mysql 安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

原文地址:http://www.cnblogs.com/bookwed/p/5896619.html


安装环境:系统是 centos7.2

1、下载

    下载地址:http://dev.MysqL.com/downloads/MysqL/

    下载版本:我这里选择的5.7.17,通用版,linux下64位

2、解压

1
2
3
4
#解压
tar @H_404_40@-zxvf MysqL-5.7.18-linux-glibc2.5-x86_64. .gz
#复制解压后的MysqL目录
cp @H_404_40@-r MysqL-5.7.18-linux-glibc2.5-x86_64 @H_404_40@/usr/local/MysqL

3、添加用户组和用户

@H_404_40@groupadd MysqL
useradd @H_404_40@-g MysqL MysqL

4、安装

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
cd @H_404_40@/usr/local/MysqL/
mkdir @H_404_40@. @H_404_40@/data/MysqL
chown @H_404_40@-R MysqL:MysqL ./
@H_404_40@/bin/MysqL_install_db @H_404_40@--user=MysqL --datadir= @H_404_40@/usr/local/MysqL/data/MysqL
support-files @H_404_40@/MysqL @H_404_40@.server @H_404_40@/etc/init @H_404_40@.d @H_404_40@/MysqLd
chmod @H_404_40@755 @H_404_40@/MysqLd
/my-default @H_404_40@.cnf @H_404_40@/etc/my @H_404_40@.cnf
#修改启动脚本
vi @H_404_40@/MysqLd
#修改项:
@H_404_40@basedir= @H_404_40@/usr/local/MysqL/
datadir= @H_404_40@/usr/local/MysqL/data/MysqL
#启动服务
@H_404_40@service MysqLd start
#测试连接
/MysqL/bin/MysqL @H_404_40@-uroot
#启动MysqL
@H_404_40@service MysqLd start
@H_404_40@service MysqLd stop
#查看运行状态
@H_404_40@service MysqLd status

5、错误

Access denied for user 'root'@'localhost'

解决

1、vi /etc/my.cnf

2、在文件末尾加入:skip-grant-tables

3、 保存 my.cnf

4、重启MysqL服务;

5、在MysqL的bin目录执行:./MysqL -uroot

6、成功进入MysqL后, 执行命令: use MysqL;

7、update MysqL.user set authentication_string=password('123root') where user='root';

8、flush privileges;

9、quit;

10、修改my.cnf文件,去掉前面增加skip-grant-tables,重启MysqL服务;

11、重新连接

6、开机自启动

chkconfig --add MysqL 添加服务

chkconfig --list 显示服务列表

如果看到MysqL的服务,并且3,4,5都是on的话则成功,如果是off,则键入:chkconfig --level 345 MysqL on

reboot重启电脑

netstat -na | grep 3306,如果看到有监听说明服务启动了

猜你在找的CentOS相关文章