服务器安装mysql8.0的细节问题

环境:
腾讯云ubuntu20.04
mysql8.0

下载mysql

// 我是直接在root下安装,普通用户请加上sudo
apt-get install update
apt-get install mysql-server

配置mysql

mysql_secure_installation   按tab 建有补全信息的

说明

# mysql_secure_installation  (执行命令)

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: N(选择N,不会进行密码的强校验)
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : N(选择N,不删除匿名用户)

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N(选择N,允许root远程连接)

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N(选择N,不删除test数据库)

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y(选择Y,修改权限立即生效)
Success.

All done! 

改配置文件

这里网上好多是5.7的版本,这里的8.0版本不同
进入下面的目录,看my.cnf 里面包含的文件路径
>

请添加图片描述
在下面的目录文件下找到 bind-address = 127.0.0.1 ,并注释。在这里插入图片描述

远程访问(navicat)

mysql -u root -p (默认没有密码,后面可以设置)
use mysql (切换数据库)
查询用户表的命令(关键知不知道它里面的root的权限)
select User,authentication_string,Host from user;
quit      (直接退出,没有(), 也不用加;)

访问权限说明:host默认都是localhost访问权限

host值访问权限
localhost本地连接
%本地+远程连接
#设置权限与密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';  
(上面的貌似没用)
// 密码设置为空密码
UPDATE mysql.user SET authentication_string='' WHERE user='root' and host='localhost';  
(如果root已经是%,这里需要改)

#刷新cache中配置
flush privileges;  

# 修改好了空密码应该可以用navicat连接的(下面是加上密码的)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则,此例中密码为空,此处的password删掉即可,只留下 ''(此处为英文单引号)。
(上面的localhost 根据自己的情况修改%)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码,此例中密码为空,此处的password删掉即可,只留下 ''(此处为英文单引号)。

FLUSH PRIVILEGES; #刷新权限 
接下来就可以登陆了

# 查看mysql的状态
systemctl status mysql.service
# 停止
service mysql stop
# 启动
service mysql start
# 重启
service mysql restart

在这里插入图片描述
下面的我的一篇关于分布式存储的文章
https://blog.csdn.net/qq_39486027/article/details/121739759

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值