This is a question I have heard (too) many time. How does one reset the root MySQL password on Ubuntu. In order to make this as simple as possible I created a shell script (you can see it below) that does just that.
What does it do?
I’m glad you ask, because just trusting someone on the internet probably isn’t such a great idea. I have added a couple of comments to the script in order to make it more readable, so please look over it before you use it.
Here is exactly what the script does:
- Asks for confirmation
- Stops MySQL
- Starts MySQL without grant tables
- Waits a couple of seconds for MySQL to start
- Generates new password of random length
- Changes root password in MySQL
- Stops insecure MySQL
- Starts the MySQL service again
- Exits and prints your new password
How to:
- Save the script locally on the MySQL host
- Run the script as root or using sudo
$ sudo bash mysql_pwd_reset.sh
- Save the new password
- Delete the script, just in case
The Script
Here are some other posts you may like
Here is a guide for setting up SFTP users who's access is restricted to their home directory. Add the following to the end of the /etc/ssh/sshd_config file: Subsystem sftp internal-sftp # This section must be placed at the very end of sshd_config Match Group sftponly ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding…
Electric power companies, in general, are pretty much the same. Tibber however, is unlike any electricity company I had seen before. They try to utilise the data we get from smart devices, which they also sell, to save electricity, money and the environment, as well as improving comfort. It’s a…
Today I have been playing around with Varnish, SSL and SPDY in relation to WordPress hosting. Now, one thing that I noticed was that several images were using the http protocol instead of https – which seemed to be caused by wp_get_attachment_url. Luckily we can use the WordPress filters to…