We’ll walk through installing MySQL and connecting it to Visual Studio Code (VSCode), then creating your first database and table.
Installing MySQL
Download the latest version for your operating system from the MySQL official website. The installer is straightforward. A few steps worth paying attention to:
- Choosing the setup type: I usually pick ‘Full’ to get everything, but ‘Custom’ is fine if you are short on space or know what you need.
- Configuring the server: Defaults are fine for most setups. Make sure the port is
3306(the standard MySQL port). - Setting the root password: Choose a strong password and keep it somewhere safe. You will need it to connect.
Once installed, you can use the command line or MySQL Workbench. In this series we mostly work through VSCode.
Integrating MySQL with VSCode
Install the ‘MySQL’ extension by Jun Han:
- Open VSCode and go to Extensions (square icon in the sidebar, or
Ctrl+Shift+X). - Search for ‘MySQL’ and install the one by Jun Han.
- A MySQL icon appears in the sidebar. Click it.
Establishing your first connection
Connect VSCode to your MySQL server:
- In the MySQL explorer, click the ‘+’ to add a new connection.
- Fill in the connection details:
- Hostname:
localhost(if MySQL is on your machine) - Port:
3306 - User:
root(or another user you set up) - Password: the one you chose during installation.
- Hostname:
- Click ‘OK’. You should be connected.
Creating your first database
Right-click your server in the MySQL explorer and select ‘New Query’. Type:
CREATE DATABASE my_first_database;
Right-click in the editor and select ‘Run MySQL Query’. That creates your first database.
Creating your first table
A table holds data in rows and columns – a bit like a spreadsheet. Here is a simple example:
USE my_first_database;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL,
joined_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
USE my_first_database; switches to that database. The CREATE TABLE statement adds a users table with four columns: id, username, email, and joined_at.
Inserting data
Add a row:
INSERT INTO users (username, email) VALUES ('john_doe', 'john@example.com');
That adds a user with username john_doe and email john@example.com.
Retrieving data
Fetch everything in the table:
SELECT * FROM users;
That shows all rows in users. You now have MySQL installed, connected to VSCode, and a working database with data in it.

