1. # 查看是否有自带的MySql库,如果先有卸载
    2. rpm -qa | grep mysql
    3. # 删除mysql-lib(系统自带的版本过低)
    4. yum remove mysql-libs
    5. # 下载mysql
    6. wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar
    7. # 解压
    8. tar -xvf mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar
    9. # 依次安装mysql包(common、libs、client、server)
    10. rpm -ivh mysql-community-common-5.7.12-1.el6.x86_64.rpm
    11. rpm -ivh mysql-community-libs-5.7.12-1.el6.x86_64.rpm
    12. rpm -ivh mysql-community-client-5.7.12-1.el6.x86_64.rpm
    13. rpm -ivh mysql-community-server-5.7.12-1.el6.x86_64.rpm
    14. # 启动mysql服务
    15. service mysqld start
    16. # 查看默认密码
    17. grep 'password' /var/log/mysqld.log
    18. # [Note] A temporary password is generated for root@localhost: x2sX3Gb6+Dtm
    19. # root@localhost: 这里后面就是默认密码
    20. # 登陆
    21. mysql -uroot -p
    22. # 修改默认密码
    23. SET PASSWORD = PASSWORD('Abcd1234.');
    24. # ps:这里需要大小写数组字符相结合,不然会通不过
    25. # 刷新系统权限
    26. flush privileges;
    27. # 开启远程登录权限
    28. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abcd1234.' WITH GRANT OPTION;
    29. # 刷新系统权限
    30. flush privileges;
    31. # 接下来就可以远程登陆了