Mysql安装

Debian/Ubuntu

apt包安装

  • 配置镜像源

    • 新建mysql-community.list文件,然后在文件中写入镜像源信息

        sudo touch /etc/apt/sources.list.d/mysql-community.list
        sudo sh -c "echo 'deb https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/debian bookworm mysql-8.0 mysql-tools' > /etc/apt/sources.list.d/mysql-community.list"
      
    • 添加GPG密钥

        sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 3A79BD29
      
    • PS:MySQL 8.0.28 及更高版本包的 KeyID 为 3A79BD29,如上所示。对于早期的 MySQL 版本,keyID 是 5072E1F5。使用不正确的密钥可能会导致密钥验证错误。

  • 更新软件包信息

      sudo apt update
    
  • 以非交互式安装

    • 设置不区分大小写

        sudo debconf-set-selections <<< "mysql-server mysql-server/lowercase-table-names select Enabled"
      
    • 设置root密码(用自己密码替换mypassword)

        sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password mypassword"
        sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password mypassword"
      
    • 安装

        sudo DEBIAN_FRONTEND=noninteractive apt install -y mysql-server
      
    • 安装MySQL后变量会自动清除,如果要重复安装,需要重新设置。

文章作者: zjw57
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 zjw57's blog
Linux Mysql Linux Mysql
喜欢就支持一下吧