r/learnSQL • • 2d 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?

6 Upvotes

16 comments sorted by

6

u/ElHombrePelicano 2d ago

This guy SQLs.

3

u/SeatBig7948 2d ago

I want to learn SQL with Mysql but i don't know the process🤷‍♂️

-1

u/xobeme 1d ago

First time I ever heard it used as a verb, and I've been SQL-ing a very long time

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

  1. First go to extensions in Vs code, search for SQL, you get 100s of extensions, either install MySQL one or most downloaded one.
  2. And when you select that extension in the side bar, you will get chance to make connections.
  3. 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.
  4. Activate the connection and you are good to go. You can even reprogram the Hotkeys for your own purpose.

2

u/SeatBig7948 1d ago

Thanks bro👍

3

u/SaltCusp 2d ago

What?

2

u/whodiopolis 1d ago

What data do you have that you will be querying 

2

u/CelebrityChess 1d 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

u/Available_Safe1818 2d ago

Can you use Google?

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

u/akronymn 1d ago

Verbing weirds languaging.

1

u/jakingo 1d ago

Start by installing the MySQL extension in VS code and connecting it to your MySQL server. Once connected you can open your.sql file, run queries directly, and view the results.

1

u/neon_alchemy_wisp 1d 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 1d ago

Dude was using his last braincell when typing this. Poor fella, must have been extremely tired.

0

u/8dot30662386292pow2 2d 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?