ubuntu-18.04 安装mysql

ubuntu 系统版本


pengxiao@pengxiao-virtual-machine:~$ uname -a
Linux pengxiao-virtual-machine 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
pengxiao@pengxiao-virtual-machine:~$ 

1 更新apt源

sudo apt-get update

2 安装mysql 服务

sudo apt-get install mysql-server

udo apt isntall mysql-client

sudo apt install libmysqlclient-dev

3 查看mysql状态是否为active状态

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-10-11 15:40:05 CST; 10min ago
  Process: 5965 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=
  Process: 5956 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 5967 (mysqld)
    Tasks: 30 (limit: 1118)
   CGroup: /system.slice/mysql.service
           └─5967 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

10月 11 15:40:03 pengxiao-virtual-machine systemd[1]: Starting MySQL Community Server...
10月 11 15:40:05 pengxiao-virtual-machine systemd[1]: Started MySQL Community Server.
lines 1-12/12 (END)

也可以通过如下命令查看,可现实端口出于监听状态

sudo netstat -tap | grep mysql

pengxiao@pengxiao-virtual-machine:~$ sudo netstat -tap | grep mysql
tcp6       0      0 [::]:mysql              [::]:*                  LISTEN      5967/mysqld         

4 关闭防火墙,未后期远程访问做准备

sudo ufw disable

5 查看防火墙状态

sudo ufw status

状态应该为 inactive

Status: inactive

6 可以通过如下命令进入MySQL服务

mysql -uroot -p你的密码 # 默认情况mysql的密码为空,直接mysql -uroot -p 提示输入密码的时候直接回车就行

7 设置mysql允许远程访问,编辑/etc/mysql/mysql.conf.d/mysqld.cnf

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

注释掉bind-address = 127.0.0.1

lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
"/etc/mysql/mysql.conf.d/mysqld.cnf" 105L, 3053C 

8 保存退出,然后进入mysql服务,执行授权命令

grant all on *.* to root@'%' identified by '你的密码' with grant option;

flush privileges;

执行quit命令退出mysql服务,执行mysql的重启命令:

service mysql restart

9 通过windows下可以使用SQLyog 远程连接Ubuntu下的mysql服务

在这里插入图片描述

ok到此完成,是不是很简单。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值