Centos7 安装 Mysql最新版

通过Yum安装


  1. 在官网找到对应的rpm
    <pre>http://dev.mysql.com/downloads/repo/yum/</pre>
  2. 点击download进入下载
    <pre>http://dev.mysql.com/downloads/file/?id=459921</pre>
  3. 在页面底部有个名为《 No thanks, just start my download.》的链接,这个链接就是下载地址。
    <pre>http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm</pre>
  4. 在服务器上安装rpm
    <pre>rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm</pre>
  5. 更新yum
    <pre>yum update</pre>
  6. 安装mysql
    <pre>yum install -y mysql-community-server</pre>
  7. 开启mysql服务
    <pre>systemctl start mysqld.service</pre>
  8. 获取mysql默认密码
    <pre>grep 'temporary password' /var/log/mysqld.log</pre>

2015-11-30T03:16:23.337689Z 1 [Note] A temporary password is generated for root@localhost: ylW?D-q+l6Ip

命令运行后得到上面一句字符串,其中ylW?D-q+l6Ip就是密码

  1. mysql安全配置
    <pre>mysql_secure_installation</pre>
  • Enter password for user root:
    输入刚刚得到的密码
  • New password:
    输入新的密码
  • Re-enter new password:
    重复输入新的密码
  • Change the password for root ? ((Press y|Y for Yes, any other key for No)
    是否想改变root的密码,输入Y,重复设置密码。
  • Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No)
    输入Y
  • Remove anonymous users? (Press y|Y for Yes, any other key for No)
    删除匿名用户,输入Y
  • Disallow root login remotely? (Press y|Y for Yes, any other key for No)
    是否禁止远程登录,输入N,(但事后发现还是不能远程登录,可以试试Y)
  • Remove test database and access to it? (Press y|Y for Yes, any other key for No)
    是否删除test数据库,输入N
  • Reload privilege tables now? (Press y|Y for Yes, any other key for No)
    是否重新加载权限表,输入Y
  1. 安装完成
    可以通过mysql -uroot -p登录,密码是刚刚设置的
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容