CentOS7下MySQL的安装与配置

前述

  CentOS7默认不支持MySQL,使用yum install mysql 安装的是mariadb,mariadb是mysql一个开源分支,所以我们需要配置新的yum源来进行MySQL的安装

操作

  步骤1: 下载安装MySQL的yum源(这里版本选的5.7)

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

     yum localinstall mysql57-community-release-el7-8.noarch.rpm 

  步骤2: 清理yum缓存: 

     yum clean all && yum makecache 

  步骤3: 按需要安装相应的包

     yum -y install mysql-community-client  # 客户端

     yum -y install mysql-community-server  # 服务端 

扫描二维码关注公众号,回复: 727709 查看本文章

     yum -y install mysql-community-devel  # 开发库

  步骤4: 启动MySQL服务,需要安装服务端 mysql-community-server

     systemctl start mysqld 

  步骤5: 设置root用户密码,默认密码为空,命令行直接敲 mysql就可以连接

     mysqladmin -u root password "newpass" 

    如提示: mysqladmin: unable to change password; error: 'Column count of mysql.user is wrong. Expected 45, found 42. Created with MySQL 50556, now running 50722. Please use mysql_upgrade to fix this error.'

    执行: mysql_upgrade

  步骤6: 连接MySQL

     mysql -u root -pnewpass  # 注意 -p后面不能有空格

    

猜你喜欢

转载自www.cnblogs.com/qq1207501666/p/9032693.html