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 密码:

     
  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
发布了94 篇原创文章 · 获赞 32 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_32596527/article/details/97620654
今日推荐