Ubuntu 19.04 安装 MySQL 5.7.27 Community(社区版)Server

  1. 下载需要的包:
    下载顺序就是安装顺序。
    wget http://repo.mysql.com/apt/ubuntu/pool/mysql-5.7/m/mysql-community/mysql-community-client_5.7.27-1ubuntu19.04_amd64.deb
    
    wget http://repo.mysql.com/apt/ubuntu/pool/mysql-5.7/m/mysql-community/mysql-client_5.7.27-1ubuntu19.04_amd64.deb
    
    wget http://repo.mysql.com/apt/ubuntu/pool/mysql-5.7/m/mysql-community/mysql-community-server_5.7.27-1ubuntu19.04_amd64.deb
  2. 安装 MySQL 依赖:
    sudo apt-get install libaio1 libmecab2
  3. 安装 MySQL 并设置 root 密码:
    sudo dpkg -i mysql-community-client_5.7.27-1ubuntu19.04_amd64.deb
    
    sudo dpkg -i mysql-client_5.7.27-1ubuntu19.04_amd64.deb
    
    sudo dpkg -i mysql-community-server_5.7.27-1ubuntu19.04_amd64.deb
    安装最后一个包时,会弹窗,让你设置 root 密码:
    Ubuntu 19.04 安装 MySQL 5.7.27 Community(社区版)Server_第1张图片
     
  4. 安装完成自动启动,包括设置开机自启。
     
  5. 登录:
    Server version: 5.7.27 MySQL Community Server (GPL)
    xuxiaowei@virtual-machine:~$ mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.7.27 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> 
    
  6. 安装完成自动启动,包括设置开机自启。
    1. 查看状态:
      systemctl status mysql.service
    2. 关闭:
      systemctl stop mysql.service
    3. 开启:
      systemctl start mysql.service
    4. 查看开机启动:
      systemctl list-unit-files |grep mysql
      
    5. 关闭开机启动:
      需要使用 root 进行操作。
      systemctl disable mysql.service
    6. 打开开机启动:
      需要使用 root 用户进行操作。
      systemctl enable mysql.service

你可能感兴趣的:(MySQL,Ubuntu,MySQL,Ubuntu)