【ubuntu20.04 mysql8.0.27安装卸载,创建用户,授权等】

4 篇文章 0 订阅
1 篇文章 0 订阅

ubuntu20.04 mysql8.0.27安装卸载,创建用户,授权等,2021.12.4亲自跑了,很稳

mysql8.0安装卸载

换源(可不换)

vi  /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse

安装

//安装

sudo apt-get install mysql-server mysql-client

//查看版本,出现下图即成功

mysql --version

在这里插入图片描述
n

初始化

执行以下命令:

sudo mysql_secure_installation

以下根据提示输入:

Enter current password for root (enter for none):<–初次运行直接回车
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车

创建用户,授权

//进入mysql

mysql -uroot -p -h localhost -P 3306

//创建用户,mysql8.0以上必须把创建和赋予权限分开,创建失败可能是你已经创建过了这个账号,使用下文命令查看mysql用户。

create user 'root'@'%' identified by '0';

//授权root用户的远程访问

grant all privileges on *.* to 'root'@'%' with grant option;  

//创建普通用户

CREATE USER 'test'@'localhost' identified by 'test';

//授权普通用户本地访问权限

grant all privileges on *.* to 'test'@'localhost' with grant option;  

//查看mysql用户

SELECT DISTINCT User FROM mysql.user;

卸载

在这里插入图片描述
个人经验总结,全部自己做了一遍,没有任何问题。因为在弄fisco-webase中间遇到了数据库安装的问题,所以自己整了一下。今天时间是2021.12.4.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值