Centos7下安装mysql

@font-face{ font-family:"Times New Roman"; } @font-face{ font-family:"宋体"; } @font-face{ font-family:"Calibri"; } @font-face{ font-family:"Verdana"; } @list l0:level1{ mso-level-number-format:decimal; mso-level-suffix:tab; mso-level-text:"%1)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:36.0000pt;text-indent:-18.0000pt;font-family:'Times New Roman';} @list l0:level2{ mso-level-number-format:alpha-lower; mso-level-suffix:tab; mso-level-text:"%2)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:60.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level3{ mso-level-number-format:lower-roman; mso-level-suffix:tab; mso-level-text:"%3."; mso-level-tab-stop:none; mso-level-number-position:right; margin-left:81.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level4{ mso-level-number-format:decimal; mso-level-suffix:tab; mso-level-text:"%4."; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:102.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level5{ mso-level-number-format:alpha-lower; mso-level-suffix:tab; mso-level-text:"%5)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:123.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level6{ mso-level-number-format:lower-roman; mso-level-suffix:tab; mso-level-text:"%6."; mso-level-tab-stop:none; mso-level-number-position:right; margin-left:144.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level7{ mso-level-number-format:decimal; mso-level-suffix:tab; mso-level-text:"%7."; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:165.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level8{ mso-level-number-format:alpha-lower; mso-level-suffix:tab; mso-level-text:"%8)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:186.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l0:level9{ mso-level-number-format:lower-roman; mso-level-suffix:tab; mso-level-text:"%9."; mso-level-tab-stop:none; mso-level-number-position:right; margin-left:207.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level1{ mso-level-number-format:decimal; mso-level-suffix:tab; mso-level-text:"%1."; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:18.0000pt;text-indent:-18.0000pt;font-family:'Times New Roman';} @list l1:level2{ mso-level-number-format:alpha-lower; mso-level-suffix:tab; mso-level-text:"%2)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:42.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level3{ mso-level-number-format:lower-roman; mso-level-suffix:tab; mso-level-text:"%3."; mso-level-tab-stop:none; mso-level-number-position:right; margin-left:63.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level4{ mso-level-number-format:decimal; mso-level-suffix:tab; mso-level-text:"%4."; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:84.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level5{ mso-level-number-format:alpha-lower; mso-level-suffix:tab; mso-level-text:"%5)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:105.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level6{ mso-level-number-format:lower-roman; mso-level-suffix:tab; mso-level-text:"%6."; mso-level-tab-stop:none; mso-level-number-position:right; margin-left:126.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level7{ mso-level-number-format:decimal; mso-level-suffix:tab; mso-level-text:"%7."; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:147.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level8{ mso-level-number-format:alpha-lower; mso-level-suffix:tab; mso-level-text:"%8)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:168.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} @list l1:level9{ mso-level-number-format:lower-roman; mso-level-suffix:tab; mso-level-text:"%9."; mso-level-tab-stop:none; mso-level-number-position:right; margin-left:189.0000pt;text-indent:-21.0000pt;font-family:'Times New Roman';} p.MsoNormal{ mso-style-name:正文; mso-style-parent:""; margin:0pt; margin-bottom:.0001pt; mso-pagination:none; text-align:justify; text-justify:inter-ideograph; font-family:Calibri; mso-fareast-font-family:宋体; mso-bidi-font-family:'Times New Roman'; font-size:10.5000pt; mso-font-kerning:1.0000pt; } span.10{ font-family:Calibri; } span.15{ font-family:Calibri; color:rgb(5,99,193); text-decoration:underline; text-underline:single; } p.16{ mso-style-name:"List Paragraph"; mso-style-noshow:yes; margin:0pt; margin-bottom:.0001pt; text-indent:21.0000pt; mso-char-indent-count:2.0000; mso-pagination:none; text-align:justify; text-justify:inter-ideograph; font-family:Calibri; mso-fareast-font-family:宋体; mso-bidi-font-family:'Times New Roman'; font-size:10.5000pt; mso-font-kerning:1.0000pt; } span.msoIns{ mso-style-type:export-only; mso-style-name:""; text-decoration:underline; text-underline:single; color:blue; } span.msoDel{ mso-style-type:export-only; mso-style-name:""; text-decoration:line-through; color:red; } @page{mso-page-border-surround-header:no; mso-page-border-surround-footer:no;}@page Section0{ } div.Section0{page:Section0;}

推荐书籍《深入浅出MySQL》《MySQL技术内幕InnoDB存储引擎第2版》

扫码关注订阅号回复100001获取《深入浅出MySQL》下载回复100003获取《MySQL技术内幕InnoDB存储引擎第2版》


image.png

  1. 卸载mysql

使用rpm -qa | grep -i mysql命令查看已经安装的mysql

使用yum删除安装过的mysql

yum remove mysql*

使用find / -name mysql查看有没有没删除干净的文件

如果有未删除干净的文件请自行删除

  1. 安装mysql

1) wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2) yum -y install mysql57-community-release-el7-10.noarch.rpm

3) 安装mysql服务器 yum -y install mysql-community-server 等待下载文件并安装

4) 启动mysql服务 systemctl start  mysqld.service 没有提示说明启动成功。如果启动失败可能是因为冲突造成的

5) 查看mysql运行状态 systemctl status mysqld.service 如果启动成功如下图所示

6) 查看mysql生成的初始密码 grep "password" /var/log/mysqld.log

7) 使用mysql -u root -p登录mysql

8) 使用系统生成的密码登录mysql数据库并修改密码(如果不想把密码设置的过于复杂,先不用执行该步骤,执行下面9和10的操作。取消密码的校验)

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

9) set global validate_password_policy=0;

10) set global validate_password_length=1;

11) 执行第8步。并且退出mysql使用命令 exit;

12) 进入到centos的命令行。删除mysql的安装文件,防止自动更新

yum -y remove mysql57-community-release-el7-10.noarch

13) 验证刚才设置的密码是否有效 如第7步的操作

14) 设置mysql允许外部的连接 登录mysql分别执行下面的命令

use mysql; 选择数据库

select host from user where user='root';

update user set host = '%' where user ='root'; 设置mysql的root用户为%为都能连接

flush privileges; 刷新

再次执行select host from user where user='root';如下图所示:

exit;退出mysql的命令行

15) 重启mysql数据库 systemctl restart mysqld.service

16) 关闭centos的防火墙 systemctl stop firewalld.service

17) 我们使用navcat工具就可以连接到刚才安装的mysql数据库了

如有需要java架构师相关资料的或者编写外挂脚本相关资料的请加我QQ769920552

你可能感兴趣的:(mysql,centos7,安装问题)