ubuntu安装MySQL(以5.7为例)

MySql的安装及配置

安装命令:

sudo apt-get install mysql-server-5.7

不能下载(下载报错)(更换源163或者腾讯源)
换源操作:

备份:

sudo cp /etc/apt/sources.list /etc/apt/sources.list_bk

编辑:

sudo gedit /etc/apt/sources.list#或者 sudo vim /etc/apt/source.list

添加源(163源):

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

更新:

sudo apt-get update

参考链接:https://blog.csdn.net/rrrrr11111jjjjjj/article/details/117045738
安装完成:

mysql --version #查看版本

MySQL相关设置:
先查看密码:

sudo cat /etc/mysql/debian.cnf 

在这里插入图片描述

登录MySQL:

mysql -h localhost -u debian-sys-maint -p

输入上述密码后登录:
在这里插入图片描述
设置账号密码(以root账号密码为123456为例)

update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';

这步尤其重要:

update mysql.user set plugin='mysql_native_password';

更新:

flush privileges;

退出:

quit;

重启数据库:

sudo service mysql restart

以刚刚设置的账号密码登录数据库:

mysql -h localhost -u root -p123456
show variables like 'character_set_%';

在这里插入图片描述
退出:

quit;
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值