0

On the server, I've got it set up, that the root doesn't need to enter password in order to use mysql (credentials are in ~/.mylogin.cnf). Now I want to connect to the mysql remotely via SSH tunnel and I'm expecting that i won't need to enter the password.

# open the tunnel (I'm using local port 3305 because 3306 is already taken for some reason)
ssh server -L 3305:127.0.0.1:3306 -N

# now try to connect
mysql -h 127.0.0.1 -P 3305 -u root

But this doesn't work. Error says: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

What am I doing wrong?

1
  • Are you looking to do this to encrypt the data? If that is the case, Mysql/Mariadb has built in encryption that can be configured Commented Nov 16, 2017 at 11:26

3 Answers 3

2

You've set up your mysql credentials on a remote server and you're running the mysql client locally.

Please set up an instance of mysql in ~/.mylogin.cnf for localhost at port 3305.

0

You can also add -p at the end of the command to get a password prompt.

0

Are you sure that you can open an ssh connection as root? Some Linux distributions restrict root ssh access by default. Check the /etc/ssh/sshd_config file for the lines

PermitRootLogin yes
PasswordAuthentication yes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .