You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将MySQL连接到Apache Superset时遇1045权限错误求助

Fixing "Access denied for user 'supersetuser'@'localhost'" When Connecting MySQL (MAMP) to Apache Superset

Let's break down why you're hitting this 1045 error even after running the GRANT statement, and walk through actionable fixes tailored to your MAMP setup:

  • Verify the Host Mapping for Your User
    MAMP's MySQL sometimes treats localhost differently than expected. Local connections might use a socket instead of TCP/IP, which can map to 127.0.0.1 rather than localhost in MySQL's user table.
    First, run this query in MAMP's MySQL shell (usually located at /Applications/MAMP/Library/bin/mysql):

    SELECT user, host FROM mysql.user WHERE user = 'supersetuser';
    

    If you don't see an entry for supersetuser@127.0.0.1, add it with:

    GRANT ALL PRIVILEGES ON `apache_superset`.* TO 'supersetuser'@'127.0.0.1' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    

    Then update your SQLAlchemy URI to use 127.0.0.1 instead of localhost:

    mysql://supersetuser:superset@127.0.0.1:8889/apache_superset
    
  • Try Connecting via MAMP's MySQL Socket
    MAMP uses a dedicated socket file for local connections, which can bypass TCP/IP port issues. First, find the socket path (typically /Applications/MAMP/tmp/mysql/mysql.sock), then modify your URI to use it:

    mysql://supersetuser:superset@localhost/apache_superset?unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock
    

    Note: You don't need to specify port 8889 when using a socket connection.

  • Double-Check MAMP's Port Configuration
    Open MAMP's preferences, navigate to the Ports tab, and confirm MySQL is actually running on port 8889. If you've changed the port recently, restart MAMP to apply the setting fully.

  • Confirm the apache_superset Database Exists
    Permissions won't matter if the target database doesn't exist. Run this query to verify:

    SHOW DATABASES LIKE 'apache_superset';
    

    If it's missing, create it with:

    CREATE DATABASE apache_superset;
    

    Then re-run your original GRANT statement to ensure permissions are applied to the existing database.

  • Rule Out Password Escaping Issues
    If your password ever includes special characters (like @, :, or /), you'll need to URL-encode them in the URI. For example, sup@rset becomes sup%40rset. While your current password superset doesn't have this issue, it's a good thing to keep in mind for future changes.

内容的提问来源于stack exchange,提问作者Giorgos Myrianthous

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:15:27