Reinstalling MySQL or Resetting its Root Password
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
3
down vote
favorite
I am running MySQL 5.7.19, under LAMP, on two Ubuntu 16.04. This is an AWS EC2 instance.
It is some time since I installed MySQL and I have not used it so it would not be a problem if I reinstalled it. Nothing I enter for the root password works.
I tried
sudo /etc/init.d/mysql stop
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
sudo mysql -u root
Resulted in
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I then tried the procedure outlined here. When I entered
sudo apt-get install mysql-server
I got
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
When I enter
ps -aux | grep mysql
the result is
ubuntu 27152 0.0 0.0 12948 984 pts/1 S+ 12:30 0:00 grep --color=auto mysql
When I enter
mysql -u root -p
I get
Enter password:
So mysql has not been uninstalled and I cannot reconfigure it.
Update 1:
When I ran
sudo dpkg-reconfigure mysql-server-5.7
I got
update-alternatives: warning: forcing reinstallation of alternative
/etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
mysql_upgrade: [ERROR] unknown option '--~'
Upgrade process encountered error and will not continue.
mysql -u root -p
results in
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 2
I tried the following with the associated results.
ubuntu@ip-10-0-1-73:~$ sudo apt autoremove --purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Running
apt-get -f install
did not change anything.
Edit 3:
If I use
sudo mysql -u root
it take me into mysql. If I use the -p switch, it accepts anything as a password. However, when I enter
mysql> UPDATE mysql.user SET authentication_string=PASSWORD('newPassword') WHERE User='root';
I get
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
Warning (Code 1681): 'PASSWORD' is deprecated and will be removed in a future release.
I then entered
FLUSH PRIVILEGES;
and got the following message
Query OK, 0 rows affected (0.00 sec)
I then quit and still get the same result if I do not use sudo
mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 4:
I tried the following with the ensuing results.
$ sudo apt install linux-headers-4.4.0-119-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt-get -f install linux-headers-4.4.0-119- generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic linux-headers-4.4.0- 66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic
linux-headers-4.4.0-71 linux-headers-4.4.0-71-generic linux-headers-4.4.0- 72 linux-headers-4.4.0-72-generic linux-headers-4.4.0-75 linux-headers-4.4.0-75- generic
linux-headers-4.4.0-78 linux-headers-4.4.0-78-generic linux-headers-4.4.0- 79 linux-headers-4.4.0-79-generic linux-headers-4.4.0-81 linux-headers-4.4.0-81-generic
linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-headers-4.4.0-89 linux-headers-4.4.0-89-generic
linux-headers-4.4.0-91 linux-headers-4.4.0-91-generic linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic linux-image-4.4.0-112-generic
linux-image-4.4.0-64-generic linux-image-4.4.0-66-generic linux-image- 4.4.0-70-generic linux-image-4.4.0-71-generic linux-image-4.4.0-72-generic
linux-image-4.4.0-75-generic linux-image-4.4.0-78-generic linux-image-4.4.0-79-generic linux-image-4.4.0-81-generic linux-image-4.4.0-83-generic
linux-image-4.4.0-87-generic linux-image-4.4.0-89-generic linux-image-4.4.0-91-generic linux-image-4.4.0-92-generic linux-image-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
The following NEW packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
0 upgraded, 2 newly installed, 0 to remove and 224 not upgraded.
10 not fully installed or removed.
Need to get 0 B/10.8 MB of archives.
After this operation, 78.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]
(Reading database ... 512472 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-119_4.4.0-119.143_all.deb ...
Unpacking linux-headers-4.4.0-119 (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119_4.4.0-119.143_all.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0- 119/include/linux/cpufeature.h.dpkg-new' (while processing './usr/src/linux- headers-4.4.0-119/include/linux/cpufeature.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb ...
Unpacking linux-headers-4.4.0-119-generic (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119-generic_4.4.0-119.143_amd64.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0-119- generic/include/config/rtc/drv/88pm860x.h.dpkg-new' (while processing './usr/src/linux-headers-4.4.0-119-generic/include/config/rtc/drv/88pm860x.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/linux-headers-4.4.0-119_4.4.0-119.143_all.deb
/var/cache/apt/archives/linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
$df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 498080 0 498080 0% /dev
tmpfs 101440 12068 89372 12% /run
/dev/xvda1 8117828 5515716 2166836 72% /
tmpfs 507184 0 507184 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 507184 0 507184 0% /sys/fs/cgroup
tmpfs 101444 0 101444 0% /run/user/1000
mysql amazon-ec2
add a comment |Â
up vote
3
down vote
favorite
I am running MySQL 5.7.19, under LAMP, on two Ubuntu 16.04. This is an AWS EC2 instance.
It is some time since I installed MySQL and I have not used it so it would not be a problem if I reinstalled it. Nothing I enter for the root password works.
I tried
sudo /etc/init.d/mysql stop
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
sudo mysql -u root
Resulted in
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I then tried the procedure outlined here. When I entered
sudo apt-get install mysql-server
I got
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
When I enter
ps -aux | grep mysql
the result is
ubuntu 27152 0.0 0.0 12948 984 pts/1 S+ 12:30 0:00 grep --color=auto mysql
When I enter
mysql -u root -p
I get
Enter password:
So mysql has not been uninstalled and I cannot reconfigure it.
Update 1:
When I ran
sudo dpkg-reconfigure mysql-server-5.7
I got
update-alternatives: warning: forcing reinstallation of alternative
/etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
mysql_upgrade: [ERROR] unknown option '--~'
Upgrade process encountered error and will not continue.
mysql -u root -p
results in
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 2
I tried the following with the associated results.
ubuntu@ip-10-0-1-73:~$ sudo apt autoremove --purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Running
apt-get -f install
did not change anything.
Edit 3:
If I use
sudo mysql -u root
it take me into mysql. If I use the -p switch, it accepts anything as a password. However, when I enter
mysql> UPDATE mysql.user SET authentication_string=PASSWORD('newPassword') WHERE User='root';
I get
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
Warning (Code 1681): 'PASSWORD' is deprecated and will be removed in a future release.
I then entered
FLUSH PRIVILEGES;
and got the following message
Query OK, 0 rows affected (0.00 sec)
I then quit and still get the same result if I do not use sudo
mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 4:
I tried the following with the ensuing results.
$ sudo apt install linux-headers-4.4.0-119-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt-get -f install linux-headers-4.4.0-119- generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic linux-headers-4.4.0- 66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic
linux-headers-4.4.0-71 linux-headers-4.4.0-71-generic linux-headers-4.4.0- 72 linux-headers-4.4.0-72-generic linux-headers-4.4.0-75 linux-headers-4.4.0-75- generic
linux-headers-4.4.0-78 linux-headers-4.4.0-78-generic linux-headers-4.4.0- 79 linux-headers-4.4.0-79-generic linux-headers-4.4.0-81 linux-headers-4.4.0-81-generic
linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-headers-4.4.0-89 linux-headers-4.4.0-89-generic
linux-headers-4.4.0-91 linux-headers-4.4.0-91-generic linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic linux-image-4.4.0-112-generic
linux-image-4.4.0-64-generic linux-image-4.4.0-66-generic linux-image- 4.4.0-70-generic linux-image-4.4.0-71-generic linux-image-4.4.0-72-generic
linux-image-4.4.0-75-generic linux-image-4.4.0-78-generic linux-image-4.4.0-79-generic linux-image-4.4.0-81-generic linux-image-4.4.0-83-generic
linux-image-4.4.0-87-generic linux-image-4.4.0-89-generic linux-image-4.4.0-91-generic linux-image-4.4.0-92-generic linux-image-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
The following NEW packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
0 upgraded, 2 newly installed, 0 to remove and 224 not upgraded.
10 not fully installed or removed.
Need to get 0 B/10.8 MB of archives.
After this operation, 78.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]
(Reading database ... 512472 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-119_4.4.0-119.143_all.deb ...
Unpacking linux-headers-4.4.0-119 (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119_4.4.0-119.143_all.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0- 119/include/linux/cpufeature.h.dpkg-new' (while processing './usr/src/linux- headers-4.4.0-119/include/linux/cpufeature.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb ...
Unpacking linux-headers-4.4.0-119-generic (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119-generic_4.4.0-119.143_amd64.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0-119- generic/include/config/rtc/drv/88pm860x.h.dpkg-new' (while processing './usr/src/linux-headers-4.4.0-119-generic/include/config/rtc/drv/88pm860x.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/linux-headers-4.4.0-119_4.4.0-119.143_all.deb
/var/cache/apt/archives/linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
$df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 498080 0 498080 0% /dev
tmpfs 101440 12068 89372 12% /run
/dev/xvda1 8117828 5515716 2166836 72% /
tmpfs 507184 0 507184 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 507184 0 507184 0% /sys/fs/cgroup
tmpfs 101444 0 101444 0% /run/user/1000
mysql amazon-ec2
1
Did you do this:You might want to run 'apt-get -f install' to correct these
?
â George Udosen
Apr 21 at 12:55
I did try that but it did not resolve the problem. Thanks,
â OtagoHarbour
Apr 21 at 13:32
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am running MySQL 5.7.19, under LAMP, on two Ubuntu 16.04. This is an AWS EC2 instance.
It is some time since I installed MySQL and I have not used it so it would not be a problem if I reinstalled it. Nothing I enter for the root password works.
I tried
sudo /etc/init.d/mysql stop
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
sudo mysql -u root
Resulted in
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I then tried the procedure outlined here. When I entered
sudo apt-get install mysql-server
I got
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
When I enter
ps -aux | grep mysql
the result is
ubuntu 27152 0.0 0.0 12948 984 pts/1 S+ 12:30 0:00 grep --color=auto mysql
When I enter
mysql -u root -p
I get
Enter password:
So mysql has not been uninstalled and I cannot reconfigure it.
Update 1:
When I ran
sudo dpkg-reconfigure mysql-server-5.7
I got
update-alternatives: warning: forcing reinstallation of alternative
/etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
mysql_upgrade: [ERROR] unknown option '--~'
Upgrade process encountered error and will not continue.
mysql -u root -p
results in
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 2
I tried the following with the associated results.
ubuntu@ip-10-0-1-73:~$ sudo apt autoremove --purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Running
apt-get -f install
did not change anything.
Edit 3:
If I use
sudo mysql -u root
it take me into mysql. If I use the -p switch, it accepts anything as a password. However, when I enter
mysql> UPDATE mysql.user SET authentication_string=PASSWORD('newPassword') WHERE User='root';
I get
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
Warning (Code 1681): 'PASSWORD' is deprecated and will be removed in a future release.
I then entered
FLUSH PRIVILEGES;
and got the following message
Query OK, 0 rows affected (0.00 sec)
I then quit and still get the same result if I do not use sudo
mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 4:
I tried the following with the ensuing results.
$ sudo apt install linux-headers-4.4.0-119-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt-get -f install linux-headers-4.4.0-119- generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic linux-headers-4.4.0- 66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic
linux-headers-4.4.0-71 linux-headers-4.4.0-71-generic linux-headers-4.4.0- 72 linux-headers-4.4.0-72-generic linux-headers-4.4.0-75 linux-headers-4.4.0-75- generic
linux-headers-4.4.0-78 linux-headers-4.4.0-78-generic linux-headers-4.4.0- 79 linux-headers-4.4.0-79-generic linux-headers-4.4.0-81 linux-headers-4.4.0-81-generic
linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-headers-4.4.0-89 linux-headers-4.4.0-89-generic
linux-headers-4.4.0-91 linux-headers-4.4.0-91-generic linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic linux-image-4.4.0-112-generic
linux-image-4.4.0-64-generic linux-image-4.4.0-66-generic linux-image- 4.4.0-70-generic linux-image-4.4.0-71-generic linux-image-4.4.0-72-generic
linux-image-4.4.0-75-generic linux-image-4.4.0-78-generic linux-image-4.4.0-79-generic linux-image-4.4.0-81-generic linux-image-4.4.0-83-generic
linux-image-4.4.0-87-generic linux-image-4.4.0-89-generic linux-image-4.4.0-91-generic linux-image-4.4.0-92-generic linux-image-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
The following NEW packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
0 upgraded, 2 newly installed, 0 to remove and 224 not upgraded.
10 not fully installed or removed.
Need to get 0 B/10.8 MB of archives.
After this operation, 78.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]
(Reading database ... 512472 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-119_4.4.0-119.143_all.deb ...
Unpacking linux-headers-4.4.0-119 (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119_4.4.0-119.143_all.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0- 119/include/linux/cpufeature.h.dpkg-new' (while processing './usr/src/linux- headers-4.4.0-119/include/linux/cpufeature.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb ...
Unpacking linux-headers-4.4.0-119-generic (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119-generic_4.4.0-119.143_amd64.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0-119- generic/include/config/rtc/drv/88pm860x.h.dpkg-new' (while processing './usr/src/linux-headers-4.4.0-119-generic/include/config/rtc/drv/88pm860x.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/linux-headers-4.4.0-119_4.4.0-119.143_all.deb
/var/cache/apt/archives/linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
$df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 498080 0 498080 0% /dev
tmpfs 101440 12068 89372 12% /run
/dev/xvda1 8117828 5515716 2166836 72% /
tmpfs 507184 0 507184 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 507184 0 507184 0% /sys/fs/cgroup
tmpfs 101444 0 101444 0% /run/user/1000
mysql amazon-ec2
I am running MySQL 5.7.19, under LAMP, on two Ubuntu 16.04. This is an AWS EC2 instance.
It is some time since I installed MySQL and I have not used it so it would not be a problem if I reinstalled it. Nothing I enter for the root password works.
I tried
sudo /etc/init.d/mysql stop
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
sudo mysql -u root
Resulted in
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I then tried the procedure outlined here. When I entered
sudo apt-get install mysql-server
I got
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
When I enter
ps -aux | grep mysql
the result is
ubuntu 27152 0.0 0.0 12948 984 pts/1 S+ 12:30 0:00 grep --color=auto mysql
When I enter
mysql -u root -p
I get
Enter password:
So mysql has not been uninstalled and I cannot reconfigure it.
Update 1:
When I ran
sudo dpkg-reconfigure mysql-server-5.7
I got
update-alternatives: warning: forcing reinstallation of alternative
/etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
mysql_upgrade: [ERROR] unknown option '--~'
Upgrade process encountered error and will not continue.
mysql -u root -p
results in
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 2
I tried the following with the associated results.
ubuntu@ip-10-0-1-73:~$ sudo apt autoremove --purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-generic : Depends: linux-headers-4.4.0-119-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Running
apt-get -f install
did not change anything.
Edit 3:
If I use
sudo mysql -u root
it take me into mysql. If I use the -p switch, it accepts anything as a password. However, when I enter
mysql> UPDATE mysql.user SET authentication_string=PASSWORD('newPassword') WHERE User='root';
I get
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
Warning (Code 1681): 'PASSWORD' is deprecated and will be removed in a future release.
I then entered
FLUSH PRIVILEGES;
and got the following message
Query OK, 0 rows affected (0.00 sec)
I then quit and still get the same result if I do not use sudo
mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Edit 4:
I tried the following with the ensuing results.
$ sudo apt install linux-headers-4.4.0-119-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ubuntu@ip-10-0-1-73:~$ sudo apt-get -f install linux-headers-4.4.0-119- generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-headers-4.4.0-119-generic : Depends: linux-headers-4.4.0-119 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic linux-headers-4.4.0- 66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic
linux-headers-4.4.0-71 linux-headers-4.4.0-71-generic linux-headers-4.4.0- 72 linux-headers-4.4.0-72-generic linux-headers-4.4.0-75 linux-headers-4.4.0-75- generic
linux-headers-4.4.0-78 linux-headers-4.4.0-78-generic linux-headers-4.4.0- 79 linux-headers-4.4.0-79-generic linux-headers-4.4.0-81 linux-headers-4.4.0-81-generic
linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-headers-4.4.0-89 linux-headers-4.4.0-89-generic
linux-headers-4.4.0-91 linux-headers-4.4.0-91-generic linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic linux-image-4.4.0-112-generic
linux-image-4.4.0-64-generic linux-image-4.4.0-66-generic linux-image- 4.4.0-70-generic linux-image-4.4.0-71-generic linux-image-4.4.0-72-generic
linux-image-4.4.0-75-generic linux-image-4.4.0-78-generic linux-image-4.4.0-79-generic linux-image-4.4.0-81-generic linux-image-4.4.0-83-generic
linux-image-4.4.0-87-generic linux-image-4.4.0-89-generic linux-image-4.4.0-91-generic linux-image-4.4.0-92-generic linux-image-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
The following NEW packages will be installed:
linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
0 upgraded, 2 newly installed, 0 to remove and 224 not upgraded.
10 not fully installed or removed.
Need to get 0 B/10.8 MB of archives.
After this operation, 78.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]
(Reading database ... 512472 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-119_4.4.0-119.143_all.deb ...
Unpacking linux-headers-4.4.0-119 (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119_4.4.0-119.143_all.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0- 119/include/linux/cpufeature.h.dpkg-new' (while processing './usr/src/linux- headers-4.4.0-119/include/linux/cpufeature.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb ...
Unpacking linux-headers-4.4.0-119-generic (4.4.0-119.143) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0- 119-generic_4.4.0-119.143_amd64.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0-119- generic/include/config/rtc/drv/88pm860x.h.dpkg-new' (while processing './usr/src/linux-headers-4.4.0-119-generic/include/config/rtc/drv/88pm860x.h'): No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/linux-headers-4.4.0-119_4.4.0-119.143_all.deb
/var/cache/apt/archives/linux-headers-4.4.0-119-generic_4.4.0- 119.143_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
$df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 498080 0 498080 0% /dev
tmpfs 101440 12068 89372 12% /run
/dev/xvda1 8117828 5515716 2166836 72% /
tmpfs 507184 0 507184 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 507184 0 507184 0% /sys/fs/cgroup
tmpfs 101444 0 101444 0% /run/user/1000
mysql amazon-ec2
edited Apr 21 at 17:15
asked Apr 21 at 12:40
OtagoHarbour
17911
17911
1
Did you do this:You might want to run 'apt-get -f install' to correct these
?
â George Udosen
Apr 21 at 12:55
I did try that but it did not resolve the problem. Thanks,
â OtagoHarbour
Apr 21 at 13:32
add a comment |Â
1
Did you do this:You might want to run 'apt-get -f install' to correct these
?
â George Udosen
Apr 21 at 12:55
I did try that but it did not resolve the problem. Thanks,
â OtagoHarbour
Apr 21 at 13:32
1
1
Did you do this:
You might want to run 'apt-get -f install' to correct these
?â George Udosen
Apr 21 at 12:55
Did you do this:
You might want to run 'apt-get -f install' to correct these
?â George Udosen
Apr 21 at 12:55
I did try that but it did not resolve the problem. Thanks,
â OtagoHarbour
Apr 21 at 13:32
I did try that but it did not resolve the problem. Thanks,
â OtagoHarbour
Apr 21 at 13:32
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
4
down vote
To reset MySQL passord please follow the procedure from "B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems":
Stop the MySQL server by sending a normal
kill
(notkill -9
) to the
mysqld
process. Use the actual path name of the .pid file in the
following command:
kill `cat /mysql-data-directory/host_name.pid`
Use backticks (not forward quotation marks) with the cat command.
These cause the output of cat to be substituted into the kill command.
Create a text file containing the password-assignment statement on a
single line. Replace the password with the password that you want to
use.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Save the file. This example assumes that you name the file
/home/me/mysql-init
. The file contains the password, so do not save it
where it can be read by other users. If you are not logged in asmysq
l
(the user the server runs as), make sure that the file has permissions
that permitmysql
to read it.
Start the MySQL server with the special
--init-file
option:
mysqld --init-file=/home/me/mysql-init &
The server executes the contents of the file named by the
--init-file
option at startup, changing the'root'@'localhost'
account password.
Other options may be necessary as well, depending on how you normally
start your server. For example,--defaults-fil
e may be needed before
--init-file
.
After the server has started successfully, delete
/home/me/mysql-init
.
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
You can try to login asroot@ip-10-0-1-73
instead of justroot
â Romeo Ninov
Apr 21 at 15:00
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
add a comment |Â
up vote
3
down vote
First, let's fix your package manager problem. Install the missing dependencies using:
sudo apt install -f
After that, if you had already uninstalled mysql-server
, please reinstall it:
sudo apt install mysql-server
If you didn't uninstall it yet, or if reinstalling it did not prompt you for a new MySQL root password, now run (adapting the version number if necessary):
sudo dpkg-reconfigure mysql-server-5.7
That should have reset your password by now. Try logging in again as root with interactive password prompt:
mysql -u root -p
If you still get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
that most likely means that the MySQL server is not running. Try starting it with:
sudo systemctl restart mysql
After that, systemctl status mysql
should report it as "active(running)". Try logging in again then.
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest tryingsudo apt autoremove --purge mysql-server
followed bysudo apt install mysql-server
.
â Byte Commander
Apr 21 at 14:27
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Can you trysudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.
â Byte Commander
Apr 21 at 15:09
 |Â
show 1 more comment
up vote
0
down vote
accepted
Finally sorted it out.
First, found and remove all instances of my.cnf.bak. Also removed /etc/alternatives/my.cnf, /var/lib/dpkg/alternatives/my.cnf and /etc/mysql/conf.d (but backed them up). Then
sudo apt-get remove --purge mysql-*
sudo apt-get install mysql-server mysql-client
If you still get something like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
this is often resolved with
sudo service mysql start
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
To reset MySQL passord please follow the procedure from "B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems":
Stop the MySQL server by sending a normal
kill
(notkill -9
) to the
mysqld
process. Use the actual path name of the .pid file in the
following command:
kill `cat /mysql-data-directory/host_name.pid`
Use backticks (not forward quotation marks) with the cat command.
These cause the output of cat to be substituted into the kill command.
Create a text file containing the password-assignment statement on a
single line. Replace the password with the password that you want to
use.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Save the file. This example assumes that you name the file
/home/me/mysql-init
. The file contains the password, so do not save it
where it can be read by other users. If you are not logged in asmysq
l
(the user the server runs as), make sure that the file has permissions
that permitmysql
to read it.
Start the MySQL server with the special
--init-file
option:
mysqld --init-file=/home/me/mysql-init &
The server executes the contents of the file named by the
--init-file
option at startup, changing the'root'@'localhost'
account password.
Other options may be necessary as well, depending on how you normally
start your server. For example,--defaults-fil
e may be needed before
--init-file
.
After the server has started successfully, delete
/home/me/mysql-init
.
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
You can try to login asroot@ip-10-0-1-73
instead of justroot
â Romeo Ninov
Apr 21 at 15:00
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
add a comment |Â
up vote
4
down vote
To reset MySQL passord please follow the procedure from "B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems":
Stop the MySQL server by sending a normal
kill
(notkill -9
) to the
mysqld
process. Use the actual path name of the .pid file in the
following command:
kill `cat /mysql-data-directory/host_name.pid`
Use backticks (not forward quotation marks) with the cat command.
These cause the output of cat to be substituted into the kill command.
Create a text file containing the password-assignment statement on a
single line. Replace the password with the password that you want to
use.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Save the file. This example assumes that you name the file
/home/me/mysql-init
. The file contains the password, so do not save it
where it can be read by other users. If you are not logged in asmysq
l
(the user the server runs as), make sure that the file has permissions
that permitmysql
to read it.
Start the MySQL server with the special
--init-file
option:
mysqld --init-file=/home/me/mysql-init &
The server executes the contents of the file named by the
--init-file
option at startup, changing the'root'@'localhost'
account password.
Other options may be necessary as well, depending on how you normally
start your server. For example,--defaults-fil
e may be needed before
--init-file
.
After the server has started successfully, delete
/home/me/mysql-init
.
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
You can try to login asroot@ip-10-0-1-73
instead of justroot
â Romeo Ninov
Apr 21 at 15:00
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
add a comment |Â
up vote
4
down vote
up vote
4
down vote
To reset MySQL passord please follow the procedure from "B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems":
Stop the MySQL server by sending a normal
kill
(notkill -9
) to the
mysqld
process. Use the actual path name of the .pid file in the
following command:
kill `cat /mysql-data-directory/host_name.pid`
Use backticks (not forward quotation marks) with the cat command.
These cause the output of cat to be substituted into the kill command.
Create a text file containing the password-assignment statement on a
single line. Replace the password with the password that you want to
use.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Save the file. This example assumes that you name the file
/home/me/mysql-init
. The file contains the password, so do not save it
where it can be read by other users. If you are not logged in asmysq
l
(the user the server runs as), make sure that the file has permissions
that permitmysql
to read it.
Start the MySQL server with the special
--init-file
option:
mysqld --init-file=/home/me/mysql-init &
The server executes the contents of the file named by the
--init-file
option at startup, changing the'root'@'localhost'
account password.
Other options may be necessary as well, depending on how you normally
start your server. For example,--defaults-fil
e may be needed before
--init-file
.
After the server has started successfully, delete
/home/me/mysql-init
.
To reset MySQL passord please follow the procedure from "B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems":
Stop the MySQL server by sending a normal
kill
(notkill -9
) to the
mysqld
process. Use the actual path name of the .pid file in the
following command:
kill `cat /mysql-data-directory/host_name.pid`
Use backticks (not forward quotation marks) with the cat command.
These cause the output of cat to be substituted into the kill command.
Create a text file containing the password-assignment statement on a
single line. Replace the password with the password that you want to
use.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Save the file. This example assumes that you name the file
/home/me/mysql-init
. The file contains the password, so do not save it
where it can be read by other users. If you are not logged in asmysq
l
(the user the server runs as), make sure that the file has permissions
that permitmysql
to read it.
Start the MySQL server with the special
--init-file
option:
mysqld --init-file=/home/me/mysql-init &
The server executes the contents of the file named by the
--init-file
option at startup, changing the'root'@'localhost'
account password.
Other options may be necessary as well, depending on how you normally
start your server. For example,--defaults-fil
e may be needed before
--init-file
.
After the server has started successfully, delete
/home/me/mysql-init
.
answered Apr 21 at 13:52
![](https://i.stack.imgur.com/Df1FU.jpg?s=32&g=1)
![](https://i.stack.imgur.com/Df1FU.jpg?s=32&g=1)
Romeo Ninov
39318
39318
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
You can try to login asroot@ip-10-0-1-73
instead of justroot
â Romeo Ninov
Apr 21 at 15:00
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
add a comment |Â
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
You can try to login asroot@ip-10-0-1-73
instead of justroot
â Romeo Ninov
Apr 21 at 15:00
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
I installed mysql using the default settings. Would the mysql data directory be /var/lib/mysql/? I did not see any .pid files in that directory. The only .pid files I could find were in directories under /run. E.g. /run/mysqld/mysqld.pid. Thanks,
â OtagoHarbour
Apr 21 at 14:04
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Do you have mysql daemon run? If not continue with creation of text tile.
â Romeo Ninov
Apr 21 at 14:06
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
Would "sudo /etc/init.d/mysql stop" stop the mysql daemon? I created /home/ubuntu/mysql-init with the new password, ran "mysqld --init-file=/home/ubuntu/mysql-init &" and then "sudo systemctl restart mysql". I then tried "mysql -u root -p" and entered the new password. I got "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". Thanks,
â OtagoHarbour
Apr 21 at 14:51
You can try to login as
root@ip-10-0-1-73
instead of just root
â Romeo Ninov
Apr 21 at 15:00
You can try to login as
root@ip-10-0-1-73
instead of just root
â Romeo Ninov
Apr 21 at 15:00
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
I tried that then accidentally left out the -p switch. I find when I use sudo (sudo mysql -u root), with or without the -p switch, it accepts any password. I then change the password inside mysql. However, if I leave out the "sudo", it still does not accept the new password.
â OtagoHarbour
Apr 21 at 15:40
add a comment |Â
up vote
3
down vote
First, let's fix your package manager problem. Install the missing dependencies using:
sudo apt install -f
After that, if you had already uninstalled mysql-server
, please reinstall it:
sudo apt install mysql-server
If you didn't uninstall it yet, or if reinstalling it did not prompt you for a new MySQL root password, now run (adapting the version number if necessary):
sudo dpkg-reconfigure mysql-server-5.7
That should have reset your password by now. Try logging in again as root with interactive password prompt:
mysql -u root -p
If you still get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
that most likely means that the MySQL server is not running. Try starting it with:
sudo systemctl restart mysql
After that, systemctl status mysql
should report it as "active(running)". Try logging in again then.
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest tryingsudo apt autoremove --purge mysql-server
followed bysudo apt install mysql-server
.
â Byte Commander
Apr 21 at 14:27
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Can you trysudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.
â Byte Commander
Apr 21 at 15:09
 |Â
show 1 more comment
up vote
3
down vote
First, let's fix your package manager problem. Install the missing dependencies using:
sudo apt install -f
After that, if you had already uninstalled mysql-server
, please reinstall it:
sudo apt install mysql-server
If you didn't uninstall it yet, or if reinstalling it did not prompt you for a new MySQL root password, now run (adapting the version number if necessary):
sudo dpkg-reconfigure mysql-server-5.7
That should have reset your password by now. Try logging in again as root with interactive password prompt:
mysql -u root -p
If you still get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
that most likely means that the MySQL server is not running. Try starting it with:
sudo systemctl restart mysql
After that, systemctl status mysql
should report it as "active(running)". Try logging in again then.
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest tryingsudo apt autoremove --purge mysql-server
followed bysudo apt install mysql-server
.
â Byte Commander
Apr 21 at 14:27
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Can you trysudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.
â Byte Commander
Apr 21 at 15:09
 |Â
show 1 more comment
up vote
3
down vote
up vote
3
down vote
First, let's fix your package manager problem. Install the missing dependencies using:
sudo apt install -f
After that, if you had already uninstalled mysql-server
, please reinstall it:
sudo apt install mysql-server
If you didn't uninstall it yet, or if reinstalling it did not prompt you for a new MySQL root password, now run (adapting the version number if necessary):
sudo dpkg-reconfigure mysql-server-5.7
That should have reset your password by now. Try logging in again as root with interactive password prompt:
mysql -u root -p
If you still get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
that most likely means that the MySQL server is not running. Try starting it with:
sudo systemctl restart mysql
After that, systemctl status mysql
should report it as "active(running)". Try logging in again then.
First, let's fix your package manager problem. Install the missing dependencies using:
sudo apt install -f
After that, if you had already uninstalled mysql-server
, please reinstall it:
sudo apt install mysql-server
If you didn't uninstall it yet, or if reinstalling it did not prompt you for a new MySQL root password, now run (adapting the version number if necessary):
sudo dpkg-reconfigure mysql-server-5.7
That should have reset your password by now. Try logging in again as root with interactive password prompt:
mysql -u root -p
If you still get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
that most likely means that the MySQL server is not running. Try starting it with:
sudo systemctl restart mysql
After that, systemctl status mysql
should report it as "active(running)". Try logging in again then.
answered Apr 21 at 12:59
![](https://i.stack.imgur.com/m8DYH.jpg?s=32&g=1)
![](https://i.stack.imgur.com/m8DYH.jpg?s=32&g=1)
Byte Commander
59.3k26159267
59.3k26159267
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest tryingsudo apt autoremove --purge mysql-server
followed bysudo apt install mysql-server
.
â Byte Commander
Apr 21 at 14:27
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Can you trysudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.
â Byte Commander
Apr 21 at 15:09
 |Â
show 1 more comment
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest tryingsudo apt autoremove --purge mysql-server
followed bysudo apt install mysql-server
.
â Byte Commander
Apr 21 at 14:27
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Can you trysudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.
â Byte Commander
Apr 21 at 15:09
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Thank you for your reply. Unfortunately, I am getting the errors shown under Update 1 of my question. Thanks,
â OtagoHarbour
Apr 21 at 13:32
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest trying
sudo apt autoremove --purge mysql-server
followed by sudo apt install mysql-server
.â Byte Commander
Apr 21 at 14:27
Okay, that's weird. So you say you don't need any of the data/settings related to the current mysql installation? In that case, I'd suggest trying
sudo apt autoremove --purge mysql-server
followed by sudo apt install mysql-server
.â Byte Commander
Apr 21 at 14:27
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
I have just tried that with the results shown in edit 2. Thanks,
â OtagoHarbour
Apr 21 at 14:37
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Seems my mysql has managed to get corrupted somehow. Is there a way to completely blow it away so I can do a clean install? Thanks,
â OtagoHarbour
Apr 21 at 14:57
Can you try
sudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.â Byte Commander
Apr 21 at 15:09
Can you try
sudo apt update ; sudo apt install linux-headers-4.4.0-119-generic ; sudo apt upgrade
or something like that, then try my previous comment again.â Byte Commander
Apr 21 at 15:09
 |Â
show 1 more comment
up vote
0
down vote
accepted
Finally sorted it out.
First, found and remove all instances of my.cnf.bak. Also removed /etc/alternatives/my.cnf, /var/lib/dpkg/alternatives/my.cnf and /etc/mysql/conf.d (but backed them up). Then
sudo apt-get remove --purge mysql-*
sudo apt-get install mysql-server mysql-client
If you still get something like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
this is often resolved with
sudo service mysql start
add a comment |Â
up vote
0
down vote
accepted
Finally sorted it out.
First, found and remove all instances of my.cnf.bak. Also removed /etc/alternatives/my.cnf, /var/lib/dpkg/alternatives/my.cnf and /etc/mysql/conf.d (but backed them up). Then
sudo apt-get remove --purge mysql-*
sudo apt-get install mysql-server mysql-client
If you still get something like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
this is often resolved with
sudo service mysql start
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Finally sorted it out.
First, found and remove all instances of my.cnf.bak. Also removed /etc/alternatives/my.cnf, /var/lib/dpkg/alternatives/my.cnf and /etc/mysql/conf.d (but backed them up). Then
sudo apt-get remove --purge mysql-*
sudo apt-get install mysql-server mysql-client
If you still get something like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
this is often resolved with
sudo service mysql start
Finally sorted it out.
First, found and remove all instances of my.cnf.bak. Also removed /etc/alternatives/my.cnf, /var/lib/dpkg/alternatives/my.cnf and /etc/mysql/conf.d (but backed them up). Then
sudo apt-get remove --purge mysql-*
sudo apt-get install mysql-server mysql-client
If you still get something like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
this is often resolved with
sudo service mysql start
edited May 5 at 14:03
answered May 1 at 2:37
OtagoHarbour
17911
17911
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1026930%2freinstalling-mysql-or-resetting-its-root-password%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Did you do this:
You might want to run 'apt-get -f install' to correct these
?â George Udosen
Apr 21 at 12:55
I did try that but it did not resolve the problem. Thanks,
â OtagoHarbour
Apr 21 at 13:32