"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Install MySQL on Ubuntu Without Entering a Password?

How to Install MySQL on Ubuntu Without Entering a Password?

Published on 2024-11-16
Browse:901

How to Install MySQL on Ubuntu Without Entering a Password?

Passwordless MySQL Installation on Ubuntu

Question:

How can I install MySQL on Ubuntu without having to enter a password during the process?

Background:

Installing MySQL using sudo apt-get install mysql prompts for password input, which can be inconvenient in non-interactive scenarios or when scripting the installation.

Solution:

To bypass the password prompt, use the following script:

#!/bin/bash
sudo debconf-set-selections 

Replace your_password with your desired password. For specific versions (e.g., mysql-server-5.6), specify the version as shown below:

sudo debconf-set-selections 

For mysql-community-server, use the following keys:

sudo debconf-set-selections 

You can also use debconf-get-selections to verify your settings:

sudo debconf-get-selections | grep ^mysql
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3