Reputation: 33748
Is there a simple way of setting the mysql root password on Ubuntu if I have root access and closing the database shortly is not an issue?
Upvotes: 1
Views: 4646
Reputation: 91
Open your terminal
`sudo mysql -u root
use mysql;
SELECT user, plugin FROM user;
UPDATE user SET plugin = "mysql_native_password" WHERE user = "root" ;
exit
service mysql restart`
Upvotes: 0
Reputation: 33748
If you do not have many tables this should run in 10 seconds.
pass=MyNewPass
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$pass';" > mysqlinit
sudo chown mysql:mysql mysqlinit
sudo /etc/init.d/mysql stop
sudo mysqld_safe --init-file=`pwd`/mysqlinit &
sleep 2
sudo killall mysqld
sudo /etc/init.d/mysql start
sudo rm mysqlinit
sql mysql://root:$pass@/mysql
Upvotes: 5