You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Before writing any SQL you need a running MySQL server. This lesson walks through installing MySQL on the three major platforms and confirms the installation is working.
The easiest route on macOS is Homebrew:
brew update
brew install mysql
After installation, start the server and enable it on login:
brew services start mysql
MySQL on macOS via Homebrew starts with no root password. Connect immediately with:
mysql -u root
Run the included security script to set a root password and remove test accounts:
mysql_secure_installation
On Ubuntu 22.04 and later, MySQL 8 is available directly from the default repositories:
sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql
sudo systemctl enable mysql
The installer sets up a unix_socket authentication plugin for the root account. Connect as root without a password using:
sudo mysql
Then run mysql_secure_installation to harden the installation.
Download the MySQL Installer from the official MySQL website. Run the installer and choose the Developer Default or Server Only setup type. The wizard guides you through choosing a root password, configuring the Windows service, and optionally installing MySQL Workbench and MySQL Shell.
After installation, open MySQL Shell or the mysql command prompt from the Start menu.
Connect to the server and check the version:
SELECT VERSION();
List the default databases:
SHOW DATABASES;
You should see information_schema, mysql, performance_schema, and sys. These are internal system databases — do not modify them directly.
It is best practice to avoid using the root account for application work. Create a dedicated database and user:
CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'devuser'@'localhost' IDENTIFIED BY 'StrongPassword1!';
GRANT ALL PRIVILEGES ON myapp.* TO 'devuser'@'localhost';
FLUSH PRIVILEGES;
Connect as the new user:
mysql -u devuser -p myapp
With MySQL installed, a database created, and a user configured, you are ready to start building tables.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.