title: Error: "Cannot Connect to Database Server"
body: <br/>
  <p>I am currently not able to access the local instance of MySQL from MySQL workbench home page. <br/>
  Primarilly, I was trying to install the LAMP stack on my Ubuntu PC following a video tutorial on LinkedIn learning named &quot;Installing Apache, MySQL, and PHP&quot;. <br/></p>
  <p>Firstly, I installed apache using <code>sudo apt-get install apache2</code>.<br/> Secondly, I installed PHP using <code>sudo apt-get install php libapache2-mod-php-mysql</code>.<br/>
  Then, I installed MySQL server using <code>sudo apt-get install mysql-server</code><br/>
  Added to this, I ran the mysql_secure_installation utility. When prompted some quetions, here are the answers I provided:<br/></p>
  <blockquote>
  <p>Would you like to setup VALIDATE PASSWORD component: YES <br/>
  Level of password validation policy: LOW <br/>
  New password: PASSWORD <br/>
  Re-enter password: PASSWORD <br/>
  Remove anonymous users?: SKIP <br/>
  Disallow root login remotely? SKIP <br/>
  Remove test database and access to it? SKIP <br/>
  Reload privileges tables now? SKIP <br/>
  All done!</p>
  </blockquote>
  <p>Next, I installed mysql-workbench using <code>sudo snap install mysql-workbench-community</code></p>
  <p>Once the installation was completed, I opened mysql-workbench and tried to access the local instance of MySQL through its reference on mysql-workbench home page.<br/>
  I failed and got fired an <strong>&quot;Cannot Connect to Database Server&quot;</strong> error</p>
  <p>Here is a full statement of the error:</p>
  <p><strong>Your connection attempt failed for user 'root' to the MySQL server at localhost:3306:
  An AppArmor policy prevents this sender from sending this message to this recipient; type=&quot;method_call&quot;, sender=&quot;:1.141&quot; (uid=1000 pid=23118 comm=&quot;/snap/mysql-workbench-community.mysql-workbench-community (enforce)&quot;) interface=&quot;org.freedesktop.Secret.Service&quot; member=&quot;OpenSession&quot; error name&quot;(unset)&quot; requested_reply=&quot;0&quot; destination =&quot;:1:14&quot; (uid=1000 pid=933 comm=&quot;/usr/bin/gnome-keyring-daemon --daemonize --login &quot; label=&quot;unconfined&quot;) <br/>
  Please:<br/>
  1 Check that MySQL is running on address localhost<br/>
  2 Check that MySQL is reachable on port 3306 (note: 3306 is the default, but this can be changed)<br/>
  3 Check the user root has rights to connect to localhost from your adresss (MySQL rights define what clients can connect to the server and from which machines)<br/>
  4 Make sure you are both providing a password if needed and using the correct password for localhost connecting from the host address you're connecting from.</strong><br/></p>
  <p>I went through the suggested checklist as follows: <br/></p>
  <ol>
  <li>I ran <code>mysql&gt; show global variables like 'port'</code> and found that I MySQL is running on port 3306 which is the localhost port. <br/></li>
  <li>I ran <code>netstat -tln</code> and found that a server is listening on port 3306 which is certainly MySQL. <br/></li>
  <li>I ran <code>mysql -u root -p  -h 127.0.0.1 -P 3306</code> and after entering my password when prompted, I could access the MySQL server from terminal. <br/></li>
  <li>I am not even prompted to provide a password since I get the error immediately after clicking on the reference of the local instance. <br/></li>
  </ol>
  <p>I need help, please.<br/></p>
  <p>PS: <br/></p>
  <ol>
  <li>I could not install MySQL workbench using <code>sudo apt-get install mysql-workbench</code> because I was getting the following error: <strong>&quot;E: Unable to locate the package mysql-workbench&quot;</strong>. <br/></li>
  <li>Once the mysql-workbench installation was completed, I got prompted : <strong>mysql-workbench-community 8.0.22 from Tonin Bolzan (tonybolzan) installed</strong></li>
  </ol>