59. How to connect MySQL Database in Visual Studio Code and Run MySQL Queries in VS Code (2024)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys in this video we will see how to connect to mySQL database in Visual Studio code and run the MySQL queries first step is we have to install the SQL tools extension click on extensions then search for SQL tools there must be no space between SQL and tools Okay click on it see here what it will do connecting users to many of the most common used databases okay scroll down we will see list of the databases allowed to connect individual Studio Cod see cockroach DB Maria DB Microsoft SQL Server MySQL TB post sqlite and many more Okay click on install see installation is Success also here see here we have the SQL tools extension before it was not there but if you click on this SQL tools click on add new connection see we don't have any drivers so close this one close this one for that we have to add the driver click on extensions again search for SQL tools then MySQL see here we have the MySQL driver click on see SQL tools MySQL Marb TB click on install see we have successfully installed now click on this SQL tools now click on close the this one click on ADD connection see here we have the drivers for myb MySQL and TB okay so click on MySQL then give the name for this connection I'm giving MySQL local because myql is installed on local p connection group name can be anything then Connect using server and Port socket file and connection string so I'm going with server and Port see server address is local address or if you know the IP you can give the IP CMD ip config see this is the IP you can give this IP on Windows on Linux if config see this is the IP okay you can give the IP both are same okay so I'm giving Local Host even you can give AWS auds that is endo okay or you can give AER one also okay then provide the database name if we don't know the database names yeah see I have the AR schools database so give the database name any one of them okay so I'm giving R2 SC username root then password mode see here we have the SQL tool driver credentials askon connect use empty password save as Lane text in settings so I'm going with ason connect okay Authentication Protocol default SSL default and show record default limit okay I'm not going to change anything click on test connection see here we have to provide password otherwise it will rotate like this until we provide the password so see successfully connected then click on Save connection see this is the connection information it is in Json format okay if you want to connect to end database you have to click on create end if you want to delete this connection that is this connection you have to click on this one now we have created the connection string but but not yet connected to mySQL shell to run the queries so click on this connect button or click on connect now both are same so click on this connect again we have to provide the password of the user otherwise go see we have successfully connected expand it see it has listed all the databases see here we have the all three database this is the default database comes with mySQL but a school sakila all are the user databases okay see here we have the all database expand after schools expand tables see here we have the student and students table let me query this table select star from student select the query right click run selected query see no data is there even if you go to sakila table suppose take film replace this student with it if you run like this it will throw error let me run this one run selected query see table does not ex this so we have to give the database name here database name is sakila dot okay then filims okay F then select it right click run the s Ed qu see here we got the output okay see these are the total number of rows close this one and see here we have the bookmarks we have the query history see these are the queries we have performed now in World also we can run the same way tables City okay so if we run like simply without providing database name it will throw error because the default one is R schools for other one you have to mention the for R schools need to provide the database name but remaining database we have to give the database name at the starting then give the dot Old Dot then select it right click run selected query see we have the different data see these are the output Windows okay let me close this one close this one close this one close this one if we want to disconnect to this database click on this disconnect button see it has been disconnected if you run this query it will not executed even if you right click run selected query see we have not received any output again it is asking the password because we need to connect to the database so provide the password then we will be able to execute so it is pass see access D for user okay so we have to connect click on connect then provide the password enter close this one now right click and run the selected Cod see we got the output okay if you want to delete query history you have to click on this delete button or clear button click on it see it has deleted all the data okay suppose you can also create the tables so try to create table you can also get list of the databases so databases select it right click run the selected query see these are the list of the databases to get the version of the MySQL server give the select version select the command or query right click and again run selected query or simply give the control e see select it press contr E from your see this is the version you want to rerun the query you have to click on this rerun the query see we got the same output or even if you want to run this one you have to click on it the query will be displayed on this Cory to if you want to create a table create table then test 1 2 3 S name int okay select it see if you don't provide database Name by default it will go to this connected database see edit connection it will be created in this one okay you we want to create in this F database you have to provide like this otherwise it will be created in the connected R schools because default is the database that is there in the connections Str okay select it right click run the selected it is Success if you go to world tables see we have the test one to you don't provide this one let me show you select it right click click on run selected query it has created in this one let's see you don't provide database name it will be created there even we can create the database also s create database test select it right click run see but it is not showing but if you run this show databases right click see we have the test DB see even we have the test DB here okay so in this video we have seen how to connect to mySQL database in Visual Studio code then we have seen how to run the MySQL statements or queries in vs code for more MySQL or vs code videos please subscribe my channel thank you
Info
Channel: r2schools
Views: 198
Rating: undefined out of 5
Keywords: How to connect MySQL with vscode, How to Run MySQL in Visual Studio Code, Connect With MySQL using VS CODE, Connecting to Visual Studio Code with MySQL, Connect to MySQL in VS Code, Connect MySQL with VS Code, MySQL - Running SQL queries in VS Code, MySQL in Visual Studio Code, How to run MySQL query in visual Studio Code, Visual Studio Code Postgres SQL Connection, MySQL Extension in Visual Code, MySQL Tutorials, MySQL Tutorials for Beginners, MySQL DBA Tutorials
Id: lV88ESRJPIo
Channel Id: undefined
Length: 10min 43sec (643 seconds)
Published: Mon Apr 08 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.