!/bin/bash
apt-get install -y mysql-server
通过脚本安装mysql时,如何自动输入mysql root密码
光阴似箭催人老,日月如移越少年。
If you install it with root, you don’t need a password. If you are an ordinary user and call sudo directly, you can only use methods such as expect, or change /etc/sudoers so that you do not need to enter a password.
mysql -u root -ppasswd root is the username, passwd is the user’s password
Note that there should be no space between -p and password
Is this what you mean?
DEBIAN_FRONTEND=noninteractive apt install -y mysql-server
If you install it with root, you don’t need a password.
If you are an ordinary user and call sudo directly, you can only use methods such as expect, or change /etc/sudoers so that you do not need to enter a password.
mysql -u root -ppasswd
root is the username, passwd is the user’s password
Note that there should be no space between -p and password
Is this what you mean?