MySQL — Get Started
Installing MySQL
Windows
- Download from mysql.com
- Run the installer
- Follow the setup wizard
- Set root password
macOS
# Using Homebrew
brew install mysql
brew services start mysql
Linux
# Ubuntu/Debian
sudo apt update
sudo apt install mysql-server
# Start service
sudo systemctl start mysql
Connecting to MySQL
# Command line
mysql -u root -p
# Enter password when prompted
Basic Commands
-- Show databases
SHOW DATABASES;
-- Create database
CREATE DATABASE mydb;
-- Use database
USE mydb;
-- Show tables
SHOW TABLES;
Creating First Table
-- Create users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
age INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert data
INSERT INTO users (name, email, age) VALUES
('John Doe', 'john@example.com', 25),
('Jane Smith', 'jane@example.com', 30);
-- Query data
SELECT * FROM users;
Mini Practice
Set up MySQL that:
- Installs MySQL
- Connects to the server
- Creates a database
- Creates and queries a table
Up Next
Next: Learn about MySQL Installation.
Related Topics
Frequently Asked Questions about Get Started
What is Get Started in MySQL?
Get Started is a fundamental concept in MySQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Get Started?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Get Started.
Why is Get Started important in MySQL?
Get Started is essential for MySQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.