栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

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

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

服务器安装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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/641900.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号