Navicat: 2003 - Can‘t connect to MySQL server on XXX (61 “Connection refused“) && MySQL创建新用户

    技术2025-05-26  27

    被其它的错误博客折磨

    当用Navicat远程访问MySQL时 Navicat报错:2003 - Can’t connect to MySQL server on XXX (61 “Connection refused”) 搜到的好多都是错误的,一个简单的问题折腾了好久

    从头开始,这次在ubuntu20.04LTS 挺好的流程介绍 https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

    下载MySQL sudo apt-get install mysql-server 直接进入MySQL sudo mysql 创建新用户 yourusername:你的用户名 permission:localhost本地访问/%可以本地和远程访问 yourpassword:你的密码 create user 'yourusername'@'permission' identified by 'yourpassword'; 给权限 grant all privileges on *.* to 'yourusername'@'permission'; 重载权限 flush privileges;

    这时你用Navicat远程访问会出现标题错误 解决步骤: https://help.navicat.com/hc/en-us/articles/217790698-2003-Can-t-connect-to-MySQL-server-on-xxx-10061-

    检查mysql是否运行 sudo systemctl status mysql.service 检查监听端口 netstat -ln | grep mysql 修改MySQL配置 ubuntu20.04LTS 文件名称可能和我的不一样 cd /etc/mysql/mysql.conf.d sudo vim mysqld.cnf 修改里面bind-address = 0.0.0.0 重启MySQL sudo systemctl restart mysql.service

    OVER,加油!

    Processed: 0.012, SQL: 12