I can't get mysql working with Ubuntu 16.04 on a Dell XPS-13 9360, mysql version 5.7.17. There seem to be two problems:
1) I can’t log in as root, or superuser, or start mysql in safe mode.
2) The folder /var/run/mysqld
is removed when the service is stopped.
Here are the details;
I’ve purged and reinstalled mysql by running these commands (source) in the terminal:
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
Reinstalled it with:
sudo apt-get dist-upgrade
sudo apt-get install mysql-server
After installation, when I type either of these commands in the terminal:
mysql -uroot
or
sudo mysql -u root
I see this message:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
I tried to start mysql in safe mode by these commands:
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
which fails with this message:
2017-04-26T08:54:42.307043Z mysqld_safe Logging to syslog.
2017-04-26T08:54:42.309096Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-04-26T08:54:42.311019Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-04-26T08:54:42.313024Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
I can get mysql working temporarily by entering these commands which I found at After fresh install of mysql-server, can't log in with mysql root -u
:
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo mysqld_safe --skip-grant-tables &
This replaces the missing file and starts mysql in safe mode. Then in a new terminal:
mysql -uroot
SET PASSWORD for root@localhost = password('test')
FLUSH PRIVILEGES
\q
stop and restart mysql in normal mode
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
After this I can log in using either:
sudo mysql -uroot
or
mysql -u root -p
BUT if I stop and restart the service again, then I can’t log in. If I enter:
sudo mysql -uroot
I see this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Also when I reboot the computer, the whole problem recurs.
I tried the workaround in this bug; I created a file mysql.conf
containing this code:
# systemd tmpfile settings for mysql
# See tmpfiles.d(5) for details
d /var/run/mysqld 0755 mysql mysql -
and I saved it in these locations:
/etc/mysql/mysql.conf.d
/etc/tmpfiles.d
But it has made no difference.
I'd be very grateful for any information that can help me get mysql working!
mysql -u root -p test
– Romeo Ninov Apr 26 '17 at 09:55I don't think it can be that I have the wrong password, because the problem recurs AFTER I set the password, login successfully, then reboot.
– Little Brain Apr 26 '17 at 10:11