Home  >  Q&A  >  body text

Ubuntu安装mysql时候如果通过shell实现自动输入密码

!/bin/bash

apt-get install -y mysql-server

通过脚本安装mysql时,如何自动输入mysql root密码

大家讲道理大家讲道理2742 days ago623

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 12:07:57

    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.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 12:07:57

    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?

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 12:07:57

    DEBIAN_FRONTEND=noninteractive apt install -y mysql-server

    reply
    0
  • Cancelreply