Database Fundamentals with MySQL / Chapter 1 — Getting MySQL running (lessons 1–3) / Lesson 1

Connecting to MySQL

Time needed: about 4 min (estimate)

☆ Read later

You can try the opening of this lesson without an account.

MySQL comes in two parts

"I installed MySQL, and now I have no idea what to do next" stops a lot of people.

One distinction makes everything after it easier.

The server (mysqld) stores data and executes SQL; it runs continuously.

The client (mysql) connects to the server and sends it SQL; it is the command you type in a terminal.

"The mysql command is missing" and "the server is not running" are two different problems.

Terminal

# macOS (Homebrew) $ brew install mysql@8.4 $ brew services start mysql@8.4 # Ubuntu / Debian $ sudo apt install mysql-server $ sudo systemctl start mysql # Docker (cleanup is easy) $ docker run --name mysql84 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 -d mysql:8.4 $ mysql -u root # no password set $ mysql -u root -p # prompts for a password mysql>

Your first query

Create a free account to keep reading

With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.

Report a problem with this lesson

Log in to send a report.

Keyboard shortcuts

Keys available in a lesson
KeyAction
[ or Alt + ←Go to the previous lesson
] or Alt + →Go to the next lesson
?Open this list
EscClose this list

The keys do not work while the cursor is in a code editor or an input field.