Before running the install verify you do not already have it installed with
which mysql
Verify your version of mysql with mysql -V
.
Your output should look something like:
mysql Ver 8.0.28 for macos12.2 on arm64 (Homebrew)
We are looking for the version number 8^
If you have a version lower than 8 you will need to uninstall mysql and reinstall the latest version. Check out their docs for more information.
Install through Brew:
brew install mysql
You can then verify the install with:
brew services list
Output should like as follows:
Name Status User File
mysql started Hart ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
If your status is set to none
you will need to start the service before you will have access to the mysql shell.
You can start it with:
brew services start mysql
Your output for the command should be as so:
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
We will install with apt manager.
First step we always want to update the current available packages.
sudo apt update
Once that has completed we will install mysql
sudo apt install mysql-server
Confirm that you have the correct version:
mysql --version
We are looking for the version number 8^
To start the service we will need to use:
sudo service mysql start
mysql -u root
Output should be as so:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28 Homebrew
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql -u root -p name_of_database -t < name_of_file.sql
\q
exit
CREATE DATABASE name;
USE name;
DROP DATABASE name;
SHOW TABLES;
DESCRIBE table_name;
DROP TABLE name;
For more examples of queries. Checkout the queries directory