CentOS MySQL5.7 安装

版权声明:本文为博主原创文章,转载需添加原文链接。 https://blog.csdn.net/makenothing/article/details/85179894

主要记录yum源的安装方式

yum源安装方式

  1. 下载yum源: wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
  2. 安装yum源: yum install mysql57-community-release-el7-8.noarch.rpm
  3. 检查mysql源是否安装成功:yum repolist enabled | grep "mysql.*-community.*"
  4. 选择Mysql的版本:修改文件 vim /etc/yum.repos.d/mysql-community.repo源。例如要安装5.6版本,将5.7的源的enabled = 1修改为enabled = 0。然后再将5.6源的enabled=0改成enabled=1即可。默认5.7
  5. 安装MySQL:yum install -y mysql-server
  6. 启动Mysql:$ systemctl start mysqld 或者service mysqld start此处需要输入系统root密码来授权。启动一次后,mysql的root密码会随机生成一个,然后才能修改mysql的root密码。
    ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
    Authentication is required to manage system services or units.
    Authenticating as: root
    Password:
    ==== AUTHENTICATION COMPLETE ===
  7. 修改root登录密码:安装完后密码是随机的,查看随机密码:grep 'temporary password' /var/log/mysqld.log $ grep "password" /var/log/mysqld.log
    2018-12-21T15:49:59.010099Z 1 [Note] A temporary password is generated for root@localhost: 1X3YQetYYw(5
  8. 使用随机密码登陆Mysql:mysql -u root -p -h 127.0.0.1 -P 3306,如果不修改密码,不能进行任何操作。必须修改的 。
  9. 修改密码:alter user 'root'@'localhost' identified by '新密码';
  10. 最后记得刷新权限;
    flush privileges

猜你喜欢

转载自blog.csdn.net/makenothing/article/details/85179894
今日推荐