I would like to connect to mysql on ubuntu 20.04 in wsl-2 without root.
Initially I had to change the port (it was used by the system):
[mysqld]
mysqlx-port=11111
I can connect with the command using sudo mysql -u root -p
but I can't access mysql without sudo, even after following instruction in the post
Trying to connect without sudo
, using mysql -u root -p
I get the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)
If I change protocol with the command mysql -u root -p --protocol=tcp
I get the error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Any clue how to get mysql 8 to work without sudo on ubuntu 20.04/wsl-2?
The first thing that comes to my mind when I see your post is:
Why you don't use aliases for this?
To set aliases, you should use any file that the shell reads when starting the session, for an interactive session, bash
reads ~/.bashrc
. So if you put your alias
definition there, it will available on any interactive bash instance:
echo 'alias mysql="sudo mysql"' >> ~/.bashrc
To make it available from the running session, source the file:
source ~/.bashrc
This may not be a perfect solution, but it would still be quite useful to avoid wasting time debugging and executing complex commands in MySQL. I hope I helped in some way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.