r/learnSQL • u/SeatBig7948 • 1d ago
MySQL
I want to understand how to use MySQL on VS code and run the code SQL in MySQL,and connect the file SQL in SQL tools?
2
u/rs047 1d ago
I have limited knowledge using SQL, but I think I know what you want to do.
First it doesn't matter if you have installed MySQL in your machine or not. But there are SQL connectors extensions in VScode
First go to extensions in Vs code, search for SQL, you get 100s of extensions, either install MySQL one or most downloaded one.
And when you select that extension in the side bar, you will get chance to make connections.
Then add the server , if it's local, then select root as username and the root password you used in the beginning while setting up SQL server in your local machine, if the server is online, then you can do the same using server username and password.
Activate the connection and you are good to go. You can even reprogram the Hotkeys for your own purpose.
2
3
2
2
u/CelebrityChess 17h ago
MySQL Server is the database; VS Code is just the editor/client. Install and start MySQL Community Server first, then add the SQLTools extension plus its MySQL/MariaDB driver (or use MySQL's VS Code extension), connect to localhost on port 3306 with your database user, open the .sql file, select that connection and run the query. If you share your OS, someone can give exact install steps.
1
1
u/Discordbothost 1d ago
The .sql file is just text; MySQL Server runs the queries and stores the data. In VS Code, SQLTools needs its MySQL driver too. Start the server, add a connection with its host, port, database and login, then run SELECT 1; to check it works before running your file.
1
1
u/neon_alchemy_wisp 20h ago
you need the MySQL server software installed on your machine first because VS Code is just a text editor and cannot run queries by itself. Once the server is running open SQLTools in VS Code add a new connection with your host port user and password then select your database to execute any .sql file.
1
u/Altruistic-Log-6292 15h ago
Dude was using his last braincell when typing this. Poor fella, must have been extremely tired.
0
u/8dot30662386292pow2 1d ago
Why mysql? Sqlite is better start. Download sqlitebrowser and you are good to go.
If you already have a mysql database server or if you insist on installing a database server, then you can use mysqlworkbench to connect to said database server.
0
u/Embarrassed_Leg_8134 1d ago
Don't you know this is Reddit and you cannot ask questions about attempting to learn anything? lol. Seriously, are you just getting started with using databases and want to know the best way to start; or are you really just wanting to use VSCode for dealing with databases?
6
u/ElHombrePelicano 1d ago
This guy SQLs.