Ubuntu: MySQL Workbench: AppArmor policy: Cannot connect to database server
On my Ubuntu (18.04) Workstation, run MySQL Workbench (previously run it on Windows Workstation that shared to a colleague that time).
It could not connect to the server.
As AppArmor policy:
Cannot Connect to Database Server
An AppArmor policy prevents this
sender from sending this message to this recipient;
type="method_call",sender=":1.99" (uid-1000 pid=10559 comm="
/snap/mysql-workbench-community/5/usr/bin/mysql-wo"
label="snap,mysql-workbench-community.mysql-workbench-cimmunity
(enforce)") interface="org.freedesktop.Secret.Service"
member="OpenSession" error name="(unset)" requested_reply="0"
destination=":1.20" (uid=1000 pid=4841
common="/usr/bin/gnome-keyring-daemon --daemonize --login "
label="unconfined")
Solved it by:
1.
snap connect mysql-workbench-community:password-manager-service :password-manager-service
https://forums.mysql.com/read.php?152,686820,686870#msg-686870
2.
Check / Edit:
/etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1
3.
Because:
MySQL 5.7 and up don't support connecting as "root" in mysql-workbench so you must create a normal user and connect via that.
From the logs - /var/log/mysql/error.log:
2020-06-16T04:03:10.960181Z 20 [Note] Access denied for user 'root'@'localhost'
Required to create another account:
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
Update