在 WSL MySQL 上连接 MySQL Workbench? [英] Connect MySQL Workbench on WSL MySQL?
本文介绍了在 WSL MySQL 上连接 MySQL Workbench?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用以下内容在 WSL2 上安装了 MySQL
I have installed MySQL on WSL2 with the following
$ sudo apt remove --purge *mysql*
$ sudo rm -rf /var/lib/mysql
$ sudo apt install -y mysql-server mysql-client
invoke-rc.d: could not determine current runlevel
...
* Stopping MySQL database server mysqld [ OK ]
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
invoke-rc.d: could not determine current runlevel
Setting up mysql-server (5.7.29-0ubuntu0.18.04.1) ...
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
$ sudo service mysql start
* Starting MySQL database server mysqld No directory, logging in with HOME=/
mkdir: cannot create directory ‘//.cache’: Permission denied
-su: 19: /etc/profile.d/wsl-integration.sh:
cannot create //.cache/wslu/integration: Directory nonexistent
然后我尝试连接:
$ sudo mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)
...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
与此同时,我创建了用户 laravel
并尝试从 WSL 使用 mysql -ularavel -p
进行连接.
In the meantime I've created the user laravel
and tried to connect from WSL with mysql -ularavel -p
.
最终我尝试从 Windows 连接:
Eventually I tried to connect from Windows:
为什么这不起作用?
推荐答案
我敢打赌,您需要授予访问权限.我添加了一个新用户并授予了访问权限.
I bet you need to GRANT access. I added a new user and GRANTed access.
mysql> CREATE USER 'newguy'@'localhost' IDENTIFIED BY 'ratfink';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT ALL ON mysql.* TO 'newguy'@'localhost';
Query OK, 0 rows affected (0.01 sec)
然后尝试使用 MySQL Workbench 中的用户:newguy 和密码:ratfink 进行连接.
Then try connecting with user: newguy and password: ratfink from MySQL Workbench.
这篇关于在 WSL MySQL 上连接 MySQL Workbench?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文