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

Ubuntu 18.04 LTS下MySQL Workbench权限错误及无法连接数据库求助

解决Ubuntu 18.04 LTS中MySQL Workbench的权限错误问题

Hey there! Let's fix this common permission hiccup step by step—totally normal for new Ubuntu/MySQL users, so don't stress.

The root cause here is that when you installed MySQL Workbench with sudo apt install mysql-workbench, the system likely created the ~/.mysql directory (and its subfolders) under root ownership. Your regular user account doesn't have write access to it, so Workbench can't create the log files it needs, which breaks database connections.

Here's how to fix it:

  1. Check directory permissions first
    Open a terminal and run this command to confirm who owns the ~/.mysql directory:

    ls -ld ~/.mysql
    

    If the output shows root as the owner/group instead of your username, that's definitely the problem.

  2. Take ownership of the directory
    Replace your_username with your actual Ubuntu username (you can get this by running whoami in the terminal), then run:

    sudo chown -R your_username:your_username ~/.mysql
    

    The -R flag makes sure we recursively fix permissions for all subfolders and files inside ~/.mysql, so Workbench can access everything it needs.

  3. Verify and restart Workbench
    Run the first ls -ld command again to confirm the ownership has changed to your user. Then close all open MySQL Workbench windows, reopen it, and try connecting to your database again—this should clear up the permission error.

If you still can't connect, double-check if the MySQL service is running:

  • Check service status:
    sudo systemctl status mysql
    
  • Start it if it's not running:
    sudo systemctl start mysql
    
  • To make MySQL start automatically on boot (optional):
    sudo systemctl enable mysql
    

Also, make sure you're using the correct credentials when connecting—by default, the MySQL admin user is root, with the password you set during MySQL installation (Ubuntu 18.04's apt install usually prompts you to set this).

内容的提问来源于stack exchange,提问作者C T

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:00:11