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.

Confused by Shopify's lack of a database? 🤯 Learn how Shopify stores your theme data, from simple Settings to complex Metafields. Perfect for devs moving from WP/Laravel.

Tired of missing VS Code extensions in remote projects? Learn 4 easy ways to sync your local extensions to SSH, WSL, and Docker environments automatically.

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