美文网首页
Debian 10 使用 APT 安装 mysql

Debian 10 使用 APT 安装 mysql

作者: 网络小乙 | 来源:发表于2021-10-09 16:41 被阅读0次

    Debian 10系统中默认使用了MariaDB,在APT的软件源中并没有mysql。所以,Debian 10 如果要安装mysql,需要下载安装Mysql APT Repository,更新APT Repository 后再使用 apt-get 安装。

    1. 设置软件源
      点击mysql下载地址,下载Mysql APT Repository(仅限Debian和ubuntu)

      下载Mysql APT Repository(这里使用mysql-apt-config_0.8.19-1_all.deb)后,在命令行执行如下命令
      sudo apt-get install ./mysql-apt-config_0.8.19-1_all.deb
      
      根据提示安装Mysql APT Repository即可。
    2. 安装mysql
      执行命令
      sudo apt-get update
      
      Hit:1 https://mirrors.aliyun.com/docker-ce/linux/debian buster InRelease
      Hit:2 http://repo.mysql.com/apt/debian buster InRelease                                                                                                                  
      Hit:3 http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates InRelease                                                                                       
      Hit:4 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease                                                                                                      
      Hit:5 https://mirrors.tuna.tsinghua.edu.cn/debian buster InRelease                                                                                                       
      Hit:6 https://mirrors.tuna.tsinghua.edu.cn/debian buster-updates InRelease                                                                                   
      Hit:7 https://dl.yarnpkg.com/debian stable InRelease                                                                     
      Hit:8 https://deb.nodesource.com/node_13.x buster InRelease
      Get:9 http://repo.mysql.com/apt/debian buster/mysql-8.0 Sources [951 B]
      Get:10 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 Packages [6,017 B]
      Fetched 6,968 B in 4s (1,807 B/s)
      Reading package lists... Done
      
      可以看到Mysql APT Repository已经被安装,下面就可以正常使用apt-get安装mysql了。
      apt-get install mysql-server
      

      然后根据提示设置密码,设置密码安全验证方式(推荐强验证方式)。


    3. 处理mysql服务安全问题
      执行如下命令进行安全设置:
      test@test:~$ mysql_secure_installation 
      
      Securing the MySQL server deployment.
      
      #输入在安装mysql时设置的root密码
      Enter password for user root: 
      
      VALIDATE PASSWORD COMPONENT can be used to test passwords
      and improve security. It checks the strength of password
      and allows the users to set only those passwords which are
      secure enough. Would you like to setup VALIDATE PASSWORD component?
      
      Press y|Y for Yes, any other key for No: 
      Using existing password for root.
      #是否重设root密码
      Change the password for root ? ((Press y|Y for Yes, any other key for No) : 
      
       ... skipping.
      By default, a MySQL installation has an anonymous user,
      allowing anyone to log into MySQL without having to have
      a user account created for them. This is intended only for
      testing, and to make the installation go a bit smoother.
      You should remove them before moving into a production
      environment.
      
      #是否删除用于test的annoymous用户,如果在生产环境下建议删除
      Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
      Success.
      
      
      Normally, root should only be allowed to connect from
      'localhost'. This ensures that someone cannot guess at
      the root password from the network.
      
      #是否禁止root远程登录
      Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
      
       ... skipping.
      By default, MySQL comes with a database named 'test' that
      anyone can access. This is also intended only for testing,
      and should be removed before moving into a production
      environment.
      
      #是否删除test数据库
      Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
      
      ... skipping.
      Reloading the privilege tables will ensure that all changes
      made so far will take effect immediately.
      
      #是否让设置立即生效
      Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
      Success.
      
      All done!
      

    相关文章

      网友评论

          本文标题:Debian 10 使用 APT 安装 mysql

          本文链接:https://www.haomeiwen.com/subject/griqoltx.html