MySQL Cheat Sheet GitHub
MySQL Cheat Sheet GitHub
md Sign in Sign up
mysql_cheat_sheet.md
MySQL Locations
Mac /usr/local/mysql/bin
Windows /Program Files/MySQL/MySQL version/bin
Xampp /xampp/mysql/bin
# Current Session
export PATH=${PATH}:/usr/local/mysql/bin
# Permanantly
echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
On Windows - https://www.qualitestgroup.com/resources/knowledge-center/how-to-guide/add-
mysql-path-windows/
Login
mysql -u root -p
Show Users
Create User
CREATE USER 'someuser'@'localhost' IDENTIFIED BY 'somepassword';
Show Grants
Remove Grants
Delete User
Exit
exit;
Show Databases
SHOW DATABASES
Create Database
Select Database
USE acme;
Create Table
Show Tables
SHOW TABLES;
INSERT INTO users (first_name, last_name, email, password, location, dept, is_admin, r
Insert Multiple Rows
INSERT INTO users (first_name, last_name, email, password, location, dept, is_admin,
Select
Where Clause
Delete Row
Update Row
Modify Column
Concatenate Columns
Like (Searching)
Not Like
IN
INSERT INTO posts(user_id, title, body) VALUES (1, 'Post One', 'This is post one'),(3,
INNER JOIN
SELECT
users.first_name,
users.last_name,
posts.title,
posts.publish_date
FROM users
INNER JOIN posts
ON users.id = posts.user_id
ORDER BY posts.title;
INSERT INTO comments(post_id, user_id, body) VALUES (1, 3, 'This is comment one'),(2,
Left Join
SELECT
comments.body,
posts.title
FROM comments
LEFT JOIN posts ON posts.id = comments.post_id
ORDER BY posts.title;
SELECT
comments.body,
posts.title,
users.first_name,
users.last_name
FROM comments
INNER JOIN posts on posts.id = comments.post_id
INNER JOIN users on users.id = comments.user_id
ORDER BY posts.title;
Aggregate Functions
Group By
SELECT age, COUNT(age) FROM users GROUP BY age;
SELECT age, COUNT(age) FROM users WHERE age > 20 GROUP BY age;
SELECT age, COUNT(age) FROM users GROUP BY age HAVING count(age) >=2;
Zed-M
commented 3 months ago
NobleKiwam
commented 3 months ago
ridl27
commented 3 months ago
Niyokwizerwa250
commented 3 months ago
You are awesome! Keep doing what you are doing for the industry
saddamcrr7
commented 3 months ago
fendiversace
commented 3 months ago
Very useful!
rohankewal
commented 3 months ago
Very helpful! Thanks brad @bradtraversy
Sohel1999
commented 3 months ago
very useful!
zhouyang159
commented 3 months ago
YuanruiZhang
commented 3 months ago
Foss-Bee
commented 3 months ago
Thanks very much @bradtraversy. You always make me love programming. Keep up with the good work.
xelinel32
commented 3 months ago
thx, man)
kailichou
commented 3 months ago
Hi, there
is there anyone also struggling to add mysql to the path?
LinmeiJ
commented 2 months ago
mymmoonoa
commented about 1 month ago
nice work!
abdalahshaban
commented about 1 month ago
nice work
zaki1001
commented about 1 month ago
ball97
commented about 1 month ago
Ajmal0197
commented about 1 month ago
Thanks master
joshuaOgwang
commented about 1 month ago
Thanks
MbuguaCaleb
commented 26 days ago
samdsg
commented 23 days ago
samdsg
commented 23 days ago
i want to limit the image to only one image.. the image is a bucket with not less than four images.
imaginaries
commented 20 days ago
matthewheimark
commented 11 days ago
Zhixin-Jack-Wang
commented 5 days ago
YosiLeibman
commented 4 days ago
I have a question Mr. Brad.
i want to limit the image to only one image.. the image is a bucket with not less than four images.
Comment on gist
Sign in to comment
Desktop version