1Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
2
3Stop the MySQL Server: sudo /etc/init.d/mysql stop
4Start the mysqld configuration: sudo mysqld --skip-grant-tables &
5
6In some cases, you've to create the /var/run/mysqld first:
7
8sudo mkdir -v /var/run/mysqld && sudo chown mysql /var/run/mysqld
9Run: sudo service mysql start
10Login to MySQL as root: mysql -u root mysql
11Replace YOURNEWPASSWORD with your new password:
12
13UPDATE
14 mysql.user
15SET
16 Password = PASSWORD('YOURNEWPASSWORD')
17WHERE
18 User = 'root';
19FLUSH PRIVILEGES;
20exit;
21Note: on some versions, if password column doesn't exist, you may want to try:
22UPDATE user SET authentication_string=password('YOURNEWPASSWORD') WHERE user='root';
23
24Note: This method is not regarded as the most secure way of resetting the password, however, it works.