The easiest way to install MySQL on Windows is via the MySQL Installer, which bundles MySQL Server, MySQL Workbench, connectors, and other tools into a single setup wizard.
-- macOS: Install via Homebrew
-- brew install mysql
-- brew services start mysql
-- mysql_secure_installation
-- Ubuntu / Debian
-- sudo apt update
-- sudo apt install mysql-server
-- sudo systemctl start mysql
-- sudo systemctl enable mysql
-- sudo mysql_secure_installation
-- CentOS / RHEL / Fedora
-- sudo yum install mysql-server (CentOS 7)
-- sudo dnf install mysql-server (CentOS 8 / Fedora)
-- sudo systemctl start mysqld
-- sudo systemctl enable mysqld
-- sudo grep 'temporary password' /var/log/mysqld.log
Once installed, you can manage the MySQL service from the command line:
-- Linux (systemd)
-- sudo systemctl start mysql
-- sudo systemctl stop mysql
-- sudo systemctl restart mysql
-- sudo systemctl status mysql
-- macOS (Homebrew)
-- brew services start mysql
-- brew services stop mysql
-- brew services restart mysql
-- Windows (Command Prompt as Administrator)
-- net start MySQL80
-- net stop MySQL80
The mysql command-line client lets you connect to any MySQL server and run SQL interactively. It's the fastest way to test queries and manage databases.
-- Connect as root (will prompt for password)
-- mysql -u root -p
-- Connect to a specific database
-- mysql -u root -p shop
-- Connect to a remote server
-- mysql -h 192.168.1.100 -P 3306 -u root -p
-- Once connected, run these essential commands:
-- List all databases
SHOW DATABASES;
-- Select a database to use
USE shop;
-- List all tables in the current database
SHOW TABLES;
-- Describe a table's structure
DESCRIBE customers;
-- or shorthand:
DESC orders;
-- Show the full CREATE tl-table statement
SHOW CREATE tl-table customers\G
-- Check current database and user
SELECT DATABASE(), USER();
MySQL Workbench is the official GUI tool for MySQL. It provides a visual interface for database design, SQL development, server administration, and data migration. Key features include:
Download MySQL Workbench for free from dev.mysql.com/downloads/workbench. It's available for Windows, macOS, and Linux.
-- Create a new MySQL user
CREATE USER 'shopuser'@'localhost' IDENTIFIED BY 'SecurePass123!';
-- Grant all privileges on the shop database
GRANT ALL PRIVILEGES ON shop.* TO 'shopuser'@'localhost';
-- Grant only SELECT and INSERT on a specific tl-table
GRANT SELECT, INSERT ON shop.orders TO 'shopuser'@'localhost';
-- Apply the privilege changes
FLUSH PRIVILEGES;
-- Show grants for a user
SHOW GRANTS FOR 'shopuser'@'localhost';
-- Revoke a privilege
REVOKE INSERT ON shop.orders FROM 'shopuser'@'localhost';
-- Drop a user
DROP USER 'shopuser'@'localhost';
Explore 500+ free tutorials across 20+ languages and frameworks.