Using WSL inside Windows - A Step-by-Step Guide to Managing MySQL Databases on Ubuntu 20.04


I'm using a Windows PC and connecting to Ubuntu 20.04 LTS through WSL. I have also downloaded the *.sql file.
WSL (Ubuntu) files in Windows Explorer, enter the following path in the address bar\\wsl$ \\wsl.localhost\Ubuntu-20.04\home\<userName>\<folderName>After copying, you may notice an additional file named
<sqlfileName>.sqlZone.Identifier. This file is generated by the Windows operating system, not by Ubuntu within WSL, and is associated with Windows security features.
then access MySQL by typingmysql -u <username> -pAlternatively, you can usesudo mysql CREATE DATABASE <tutorial_database>; GRANT ALL ON <dbName>.* TO '<userName>'@'localhost'; exit; mysql -u <userName> -p
SHOW DATABASES;
*.sql file was copiedcd <databaseFolder>/ mysql -u <userName> -p <dbFolder> < <dbName>.sqlThis command will prompt for a password and might take some time to execute without displaying a progress bar. Do not worry; this is normal behavior as the SQL file is being imported into the database.
If you prefer to see a progress bar while importing the database, use the following command
pv <db>.sql | mysql -u <userName> -p <database_name>Note: The pv command may need to be installed separately if it's not already available on your system.

Stop fighting Git permissions in WSL. This post explains the root cause of the 'Permission Denied' error and shows you the permanent fix.

Discover PostgreSQL’s origins, unique features, and how it stacks up against MySQL and MariaDB. Perfect for beginners learning modern database systems.

Follow this easy tutorial to set up Ubuntu on Windows with WSL. Install, configure, and explore the Linux file system.