zoukankan      html  css  js  c++  java
  • (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 61] Connection refused)")

    本地数据库能通过root和密码正常登录

    逐一排查问题

    1,查看端口是否正确(使用的默认端口 3306)

    mysql> show global variables like 'port';

    结果端口为0

    2,修改端口号

    查看/Library/LaunchDaemons下的com.oracle.oss.mysql.mysqld.plist发现根本就没有Port相关的配置

    于是尝试解决;

    2.1,停止MySQL服务

    sudo /usr/local/mysql/support-files/mysql.server stop

    输入本机密码即可

    2.2,在com.oracle.oss.mysql.mysqld.plist文件中的ProgramArguments下添加<string>--port=3306</string>保存退出

    <key>ProgramArguments</key>
            <array>
                <string>/usr/local/mysql/bin/mysqld</string>
                <string>--user=_mysql</string>
                <string>--basedir=/usr/local/mysql</string>
                <string>--datadir=/usr/local/mysql/data</string>
                <string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
                <string>--log-error=/usr/local/mysql/data/mysqld.local.err</string>
                <string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string>
                <string>--keyring-file-data=/usr/local/mysql/keyring/keyring</string>
                <string>--early-plugin-load=keyring_file=keyring_file.so</string>
                <string>--port=3306</string>
            </array>

    重启MySQL数据库,再次查看MySQL端口,变为了 3306

    重新连接数据库,成功!


    参考:

    启动MySQL服务

    sudo /usr/local/MySQL/support-files/mysql.server start

    停止MySQL服务

    sudo /usr/local/mysql/support-files/mysql.server stop

    重启MySQL服务

    sudo /usr/local/mysql/support-files/mysql.server restart
  • 相关阅读:
    中介者模式(Mediator Pattern)
    状态模式
    命令模式(Command Pattern)
    迭代器模式(Iterator Pattern)
    解释器模式
    备忘录模式
    访问者模式(Visitor Patten)
    责任链模式(chainOfResponsibility)
    .net下安装 ZooKeeper.Net
    Zookeeper .Net客户端代码
  • 原文地址:https://www.cnblogs.com/ice5/p/13820474.html
Copyright © 2011-2022 走看看