While starting mysql server 5.7.17 using mysqld_safe, following error occcours.
2017-02-10T17:05:44.870970Z mysqld_safe Logging to \'/var/log/mysql/error.log
It seems odd that this directory was not created at install - have you manually changed the path of the socket file in the my.cfg?
Have you tried simply creating this directory yourself, and restarting the service?
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
Work for me in CentOS:
$ service mysql stop
$ mysqld --skip-grant-tables &
$ mysql -u root mysql
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
$ service mysql restart
When I used the code mysqld_safe --skip-grant-tables &
but I get the error:
mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
$ systemctl stop mysql.service
$ ps -eaf|grep mysql
$ mysqld_safe --skip-grant-tables &
I solved:
$ mkdir -p /var/run/mysqld
$ chown mysql:mysql /var/run/mysqld
Now I use the same code mysqld_safe --skip-grant-tables &
and get
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
If I use $ mysql -u root
I'll get :
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Now time to change password:
mysql> use mysql
mysql> describe user;
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed
mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('newpwd');
or If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
Alternate Method:
USE mysql
UPDATE user SET Password = PASSWORD('newpwd')
WHERE Host = 'localhost' AND User = 'root';
And if you have a root account that can access from everywhere:
USE mysql
UPDATE user SET Password = PASSWORD('newpwd')
WHERE Host = '%' AND User = 'root';`enter code here
now need to quit
from mysql and stop/start
FLUSH PRIVILEGES;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
now again ` mysql -u root -p' and use the new password to get
mysql>
You may try the following if your database does not have any data OR you have another away to restore that data. You will need to know the Ubuntu server root password but not the mysql root password.
It is highly probably that many of us have installed "mysql_secure_installation" as this is a best practice. Navigate to bin directory where mysql_secure_installation exist. It can be found in the /bin directory on Ubuntu systems. By rerunning the installer, you will be prompted about whether to change root database password.