title: Navicat SSH Tunnel (MariaDB) - Access Denied to user@localhost
body: <p>I know there are a million questions like this where the answer ends up being that the user forgot to use the correct password, or didn't know to connect to 'localhost' as the DB server or something stupid. This is not one of those questions.</p>
  
  <p>When I SSH into my server from a terminal, I'm able to connect fine. From there, I can run:</p>
  
  <pre><code>mysql -h localhost -u MyUser -pMyPassword
  </code></pre>
  
  <p>I can get into the DB just fine from the terminal.</p>
  
  <p>Using Navicat, I've set up an SSH tunnel. I've done this a thousand times before and know exactly how it works.</p>
  
  <p>On the SSH tab, I put in the REMOTE hostname. Port 22. Username is the username that I use to SSH, NOT the database username. I've used both a password and a public key. Both work fine.</p>
  
  <p>The problem seems to be the connection to the database after the SSH tunnel is established.</p>
  
  <p>On the general tab, I have the hostname set to 'localhost'. The username is MyUser, the same username which works with the mysql command in the terminal. The password is saved, and is MyPassword, the same password which works with the mysql command in the terminal. The encoding is set to UTF-8, the default.</p>
  
  <p>I've double-checked all these values a thousand times, they match exactly what works from a terminal.</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>Access denied for user 'MyUser@127.0.0.1' (using password: YES)</p>
  </blockquote>
  
  <p>It's clear from this message that the SSH tunnel works, but the connection to the database does not. Again, the values on my general tab match the values I use in the mysql terminal command (which works) exactly, but Navicat won't connect.</p>
  
  <p>I've also tried using 127.0.0.1 as the host. This produces the exact same error. It's curious to me that setting a hostname of 'localhost' throws the error with 127.0.0.1 instead of localhost, but I assume this is just set up in the server's host file and is essentially the same thing.</p>
  
  <p>I've tried this with 'Use Compression' both checked and unchecked, though unchecked is the default value.</p>
  
  <p>I've also double-checked my general tab against the configuration in a webapp which runs off the server, and it is identical. The only things I can think are:</p>
  
  <p>-MySQL is not running on port 3306 (though I wouldn't expect an access denied error if no server existed on this port to begin with).</p>
  
  <p>-UTF-8 default encoding is incorrect (though every single table in the DB is set to utf8_unicode_ci)</p>
  
  <p>Those are the only two things left which I could change, as the username and password are correct.</p>
  
  <p>I also read a guide which said to check the server's /etc/ssh/sshd_config file, and look to see if there's AllowTcpForwarding set to no. This value does not exist in that file, and I was told that the default value is yes, so I haven't added the value.</p>
  
  <p>It's worth mentioning that this is a MariaDB database, and I have the connection set to use MySQL in Navicat. I've successfully connected to MariaDB databases using the MySQL setting in the past, so I don't think should cause any issue.</p>