在windows下远程调用、连接(navicat)wsl2中 mysql 8.* 的详细步骤

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

以下操作都需要root权限

安装

$ apt update
$ apt install mysql-server

修改配置

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

修改后状态,关注

# bind-address           = 127.0.0.1
# mysqlx-bind-address    = 127.0.0.1

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket  = /var/run/mysqld/mysqld.sock
port            = 3306
datadir = /var/lib/mysql


# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
tmpdir          = /tmp
#
# 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
# mysqlx-bind-address    = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 64M
thread_stack            = 256K

thread_cache_size       = -1

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP

# max_connections        = 151

# table_open_cache       = 4000

登录、赋权、添加可以远程访问的用户

# 登录,wsl2安装的mysql默认没有密码
mysql -u root

# root用户没有SYSTEM_USER权限,需要先赋权
grant system_user on *.* to 'root';

# mysql 8.0 以后需要用如下命令开启远程服务,其中添加了 用户名/密码:test/123456 的用户
CREATE USER 'test'@'%' IDENTIFIED BY '123456';
GRANT ALL ON *.* TO 'test'@'%'; 
ALTER USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES;

重启

service mysql restart

查看wsl2的ip

 远程navicat登录

参考:

Win10连接WSL2-Ubuntu中的MySQL_Simon loves games-CSDN博客_连接wsl的mysql

​​​​​​mysql you need (at least one of) the SYSTEM_USER privilege(s) for this operation - 赵先鑫 - 博客园

Mysql 8.0.13 开启远程访问权限(ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th)_GentleCP的博客-CSDN博客

  • 15
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值