Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqladmin: connect to server at 'localhost' failed

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?

like image 514
udgru Avatar asked May 02 '15 16:05

udgru


People also ask

Can't connect to local MySQL server?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.

Can not connect to local MySQL server through socket '/ tmp MySQL sock?

It means either the MySQL server is not installed/running, or the file mysql. sock doesn't exist in /var/lib/mysql/ . There are a couple of solutions for this error. Then try to connect again.

How do I connect to a local MySQL server?

Step 3: Connect to a Local MySQL ServerEnter mysql.exe -uroot -p , and MySQL will launch using the root user. MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you'll connect to the MySQL server.

Can't connect to MySQL server on timed out?

A Connection Timed Out error occurs when the database's firewall won't allow you to connect to the database from your local machine or resource. If you are getting this error, check that you have added the machine or resource you are connecting from to the database's list of trusted sources.


1 Answers

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.

like image 95
Henning Kockerbeck Avatar answered Sep 18 '22 15:09

Henning Kockerbeck