【问题标题】:Provisioning MariaDB on Ubuntu 20.04在 Ubuntu 20.04 上配置 MariaDB
【发布时间】:2020-04-26 06:49:47
【问题描述】:

我可以在我的配置文件中使用 Ubuntu 18.04 在我以前的 vagrant box 上自动设置和设置 MariaDB 10.0 根密码

export DEBIAN_FRONTEND=noninteractive
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y mysql-server

但它不适用于 Ubuntu 20.04 和 MariaDB 10.3。我尝试通过手动安装进行测试,显然现在安装不会提示输入 root 用户的默认密码。

我只将此框用于开发环境,有没有其他方法可以自动设置root密码?

【问题讨论】:

    标签: mysql mariadb vagrant vagrantfile vagrant-provision


    【解决方案1】:

    我找到了一个简单的解决方案。显然密码确实有效,但前提是从盒子本身访问 MySQL 控制台。我只需要通过 MySQL 控制台命令添加新的 root 用户。这是我的配置文件现在的样子

    export DEBIAN_FRONTEND=noninteractive
    sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
    sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
    sudo apt-get install -y mysql-server
    
    mysql -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'root' WITH GRANT OPTION;"
    mysql -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
    mysql -u root -proot -e "FLUSH PRIVILEGES;"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 2023-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多