'MySQL Workbench cannot connect to database in Ubuntu 20.04

enter image description here

I cannot open the local instance in MySQL Workbench in Ubuntu 20.04 after installing the MySQL server. I searched for some similar topics here but these did not help.

Solution Found: I've found the solutions for this problem. This was because of the MySQL Workbench couldn't store password in keychain and also because it failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user 'root'@'localhost'(using password:YES).

Use this command in the terminal: sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service.

The snap package is sandboxed as usual and is not by default allowed to access the service. MySQLWorkbench is blocked by AppArmor when we choose "Store in keychain" option. That's why we need to enter the command to allow the package to access the service.

The solution links that helped me:

MySQL Workbench not saving passwords in keychain

Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user 'root'@'localhost'(using password:YES)



Solution 1:[1]

Make sure all the mentioned things working.

First check mysql is running by running below command:

sudo systemctl status mysql

If it's running make sure that your mysql username is root and password you are entering is correct. If still not working make sure you have given all the privileges to user "root".

If don't know how to set privileges read this article carefully.

https://docs.rackspace.com/support/how-to/install-mysql-server-on-the-ubuntu-operating-system/

Solution 2:[2]

All I need to do here is mainly type the following command in the terminal:

sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service

Here, the snap package is sandboxed as usual and is not by default allowed to access the service. MySQLWorkbench is blocked by AppArmor when we choose "Store in keychain" option. That's why we need to enter the command to allow the package to access the service.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zartash Zulfiqar
Solution 2