CentOS7安装mysql 5.7

  ping -c 4 www.baidu.com检查网络是否连通

   

  安装wget
  yum -y install wget

  添加mysql端口3306
  firewall-cmd --zone=public --add-port=3306/tcp --permanent
  重新载入
  firewall-cmd --reload

  

  下载mysql rpm文件

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

  安装文件

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

  安装MySQL服务

  yum -y install mysql-community-server

  跳过mysql密码,编辑my.cnf配置文件,按键盘字母i键,进入编辑模式

  vi /etc/my.cnf

  最下行新增skip-grant-tables

  按esc,输入 :wq 回车保存

  启动MySQL服务

  systemctl statrt mysqld

  登录MySQL,不输密码直接回车进入

  mysql -uroot -p

  重置密码为空

  use mysql;

  update user set authentication_string="" where user="root";

  exit;

  

  

  再进入刚刚的编辑文件删除添加的skip-grant-tables一行

  vi /etc/my.cnf

  新增四行,修改mysql语言

  [client]

  default-character-set=utf8

  character-set-server=utf8

  collation-server=utf8_general_ci

  

  重启MySQL服务器

  systemctl restart mysqld

  直接回车进入数据库,并设置密码,密码要有大小写和特殊符号复杂一些,否则会密码简单报错

  mysql -uroot -p

  use mysql;

  ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "Yzc.1025";

  mysql的授权,对访问mysql的主机进行授权,否则访问不了

  create user "root"@"%" identified by "****";

  grant all privileges on *.* to "root"@"%";

  flush privileges;

  

   

  查看语言状态

  status

  

原文地址:https://www.cnblogs.com/Mr-xy/p/14814535.html