美文网首页
cenos 7.5 mysql5.7.27 安装

cenos 7.5 mysql5.7.27 安装

作者: ttw076 | 来源:发表于2019-07-23 09:31 被阅读0次

    卸载宝塔面板:

    1.wget http://download.bt.cn/install/bt-uninstall.sh

    2.sh bt-uninstall.sh

    命令:

    cat /proc/version

    Linux version 3.10.0-862.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Fri Apr 20 16:44:24 UTC 2018

    uname -a

    Linux centos7-64-1 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    uname -r

    3.10.0-862.el7.x86_64

    getconf LONG_BIT

    64

    cat /etc/redhat-release

    CentOS Linux release 7.5.1804 (Core)

    rpm -qa | grep mariadb

    mariadb-libs-5.5.60-1.el7_5.x86_64

    rpm -qa | grep mysql 无结果

    正式进入安装 mysql 步骤

    1.wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

    目录多个mysql-community-release-el7-5.noarch.rpm

    执行rpm -ivh mysql-community-release-el7-5.noarch.rpm

    2.cd /etc/yum.repos.d/

    多两个文件 mysql-community.repo和mysql-community-source.repo

    3.安装 yum install mysql-server

    4.启动 service mysqld start

    5.查看状态 systemctl status mysqld 或者 service mysqld status

    显示:Active: active (running) since 一 2019-07-22 09:33:13 CST; 1h 9min ago

    卸载安装的 mysql

    在下载官网的mysql57-community-release-el7-10.noarch.rpm,执行rpm -ivh的时候报依赖检测失败:

    mysql-community-release 与 mysql57-community-release-el7-10.noarch 冲突。

    命令查看mysql安装情况:rpm -qa | grep -i mysql

    结果:

    mysql-community-common-5.7.27-1.el7.x86_64

    mysql-community-server-5.7.27-1.el7.x86_64

    mysql-community-libs-5.7.27-1.el7.x86_64

    mysql-community-release-el7-5.noarch

    mysql-community-libs-compat-5.7.27-1.el7.x86_64

    mysql-community-client-5.7.27-1.el7.x86_64

    停止 mysql: service mysqld stop

    删除命令:rpm -e 文件名

    find / -name mysql删除查找到的结果。

    再删除配置文件 rm -rf /etc/my.cnf

    mysql 初始密码的设置:

    先查看临时密码,使用命令 vi /var/log/mysqld.log ,查找到A temporary password is generated for root@localhost: 8dR!2VlJTyaq。

    mysql -u root -p 得到结果 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    猜测应该是没有开启 mysql 的原因。启动 mysql 后,使用临时密码登录成功。

    用该密码登录到服务端后,必须马上修改密码,不然会报如下错误:

    mysql>select@@log_error;
    
    ERROR1820(HY000): You must reset your password using ALTER USER statement before executing this statement.
    
    mysql>
    
    修改密码

    ALTER USER 'root'@'localhost' IDENTIFIED BY '***';
    密码的要求是大写加小写加数字且大于8位。
    这样密码就修改成功了。

    授权其他机器登录
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '***' WITH GRANT OPTION;
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> FLUSH  PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> 
    

    然而其他机器登录还是报错:2003 - Can't connect to MySQL server on '192.168.1.79' (61 "Connection refused")
    原因是因为防火墙没有开启。
    firewall-cmd --state
    firewall-cmd --list-all
    firewall-cmd --add-port=3306/tcp --permanent
    firewall-cmd --reload

    相关文章

      网友评论

          本文标题:cenos 7.5 mysql5.7.27 安装

          本文链接:https://www.haomeiwen.com/subject/oxinlctx.html