Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
连接WSL MySQL上的MySQL工作台?_Mysql_Windows Subsystem For Linux - Fatal编程技术网

连接WSL MySQL上的MySQL工作台?

连接WSL MySQL上的MySQL工作台?,mysql,windows-subsystem-for-linux,Mysql,Windows Subsystem For Linux,我已经在WSL2上安装了MySQL,并具有以下功能 $ 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

我已经在WSL2上安装了MySQL,并具有以下功能

$ 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

最后,我尝试从Windows连接:


为什么这不起作用?

我打赌您需要授予访问权限。我添加了一个新用户并授予了访问权限

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

可能是MySQL服务器未配置为服务网络连接吗?当从命令行运行时,
mysql客户端
可能会通过本地套接字进行连接(请参阅)。sudo mysql-h 127.0.0.1的输出是什么?错误是关于与服务器的连接,而不是被拒绝的权限。是的,但是没有权限,你被拒绝连接访问。不幸的是,这对我不起作用。另见: