I'm having trouble connecting to MySQL with from Ubuntu 16.04:
mysql -u root -p
which returns the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
When I try starting the server with:
sudo service mysql start
mysqld_safe --skip-grant-tables &
the output is:
# 2017-01-26T20:11:45.329764Z mysqld_safe Logging to syslog.
2017-01-26T20:11:45.333031Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:11:45.336684Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:11:45.358956Z mysqld_safe A mysqld process already exists
If I kill the process with:
ps aux | grep "msyql"
kill -9 pid
and then run:
mysqld_safe --skip-grant-tables &
I get:
2017-01-26T20:10:07.979813Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:10:07.984114Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-26T20:10:07.987546Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
It's an endless loop. So then what if I reinstalled from scratch?
First remove MySQL:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
Then reinstall:
sudo apt-get update
sudo apt-get install mysql-server
sudo mysql_install_db // (deprecated command)
sudo /usr/bin/mysql_secure_installation
As far as here:
sudo /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Access denied for user 'root'@'localhost' (using password: YES)
or:
mysqladmin -u root password [newpass]
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Then it falls down.
I've tried following all of the answers here - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Sometimes a temporary password is stored according to others, but it's not stored in /var/log/mysqld.log as suggested
Anybody able to help?