Debian安装mysql

50 篇文章 0 订阅
17 篇文章 1 订阅

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!
    

数据库



作者:网络小乙
链接:https://www.jianshu.com/p/86df485bd525
来源:简书

  • 6
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值