mysqladmin: connect to server at 'localhost' failed
Asked Answered
P

2

16

Today (2015-05-02) I upgraded my Linux system via apt-get update and
apt-get upgrade whereas mysql, mysqladmin and a lot more packages
have been updated. The mysql-server-5.5 runs and I can login and do all
the typical database operations but when I type:

user@ubuntu:~# mysqladmin proc

I get the following error:

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Formerly I could solve this issue by simple setting the mysql root password new.
This does not solve the issue anymore:

user@ubuntu:~# sudo dpkg-reconfigure mysql-server-5.5

How do I get the mysqladmin up again without reinstalling mysql?

Plop answered 2/5, 2015 at 16:18 Comment(0)
I
26

Short version: If your MySQL user root needs a password to connect, it might be a good idea to have mysqladmin provide that password ;)

Longer version: Your MySQL user root seems to need a password to connect

setting the mysql root password new

But mysqladmin tries to connect without a password

'Access denied for user 'root'@'localhost' (using password: NO)'

And mysqladmin does that because you're not telling it otherwise ;)

mysqladmin, like other MySQL-related command line tools (mysql, mysqldump, mysqlshow etc.), offers options to provide such access data.

  • h: Which host to connect to. If not provided, localhost is assumed
  • u: Which user to connect as. If not provided, root is assumed
  • p: Which password to use. If not provided, no password is used

You should be able to use something like

mysqladmin -uroot -pmysupersecretpassword proc

(be aware that there's no space between the options and their values). You can also have MySQL ask you for the password like

mysqladmin -uroot -p proc

With that, MySQL should give you a prompt where you can enter your password.

Iyeyasu answered 3/5, 2015 at 10:49 Comment(2)
Hello, this solved my problem but I have a question. I am not able to login using mysqladmin --defaults-file=/etc/mysql/debian.cnf , contains of debian.cnf: https://paste.ubuntu.com/p/n7n8zTZBM2/ can you able to help me?Chindwin
@Chindwin Judging from first glance, what you're doing should work. But comments on existing questions and answers aren't meant to ask new questions. That's what, well, new questions are for ;) So I would advise you to search whether another question or answer solves your specific problem, and if there's none, ask a new question about it.Iyeyasu
W
0

Everything is going good and fine except for being able to get MySQL to work, Everything was working fine except status was failed.

MySQL Service Status

Try this if you are working in fedora 3x

sudo rm -rf /var/lib/mysql
sudo dnf install community-mysql-server
sudo systemctl start mysqld.service

After this try

sudo dnf reinstall community-mysql-server
Wild answered 20/6, 2020 at 11:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.