MySQL Basics

Jackbox

Active Member
Joined
Jan 2, 2016
Messages
152
Points
74
Age
25
Whether you are working with MySQL or MariaDB, this is going to probably work perfectly well for you. This is a cheat sheet I have decided to make for database navigation/viewing while developing or testing.

Before we get started I would like to stress that using a GUI is possible and many people do that, this tutorial covers executing queries. You can even use a web interface: Adminer, phpMyAdmin, Navicat, SequelPro (Mac), HeidiSQL

Requirements: You must have MySQL or MariaDB installed on your operating system. Listed are some install guides.
First, let's go ahead and open SSH (get in a terminal).

Code:
mysql -p
Authenticate with your password.

  1. show databases;
    upload_2017-8-10_16-54-21.png
  2. use fun;
  3. show tables;
    upload_2017-8-10_16-55-16.png
  4. select * from users;
Before I dox myself how about I take out some information, eh?

Code:
update fun.users set name = 'nobody' where id > 0;
Notice the structure of the above query is: UPDATE databaseName.tableName SET columnName = 'content' where id > 0;

Code:
select id, name from users;
upload_2017-8-10_17-11-16.png

What about generating random integers to write atop emails?

upload_2017-8-10_17-17-43.png

I plan on continuing this. If anyone has requests or ideas for the cheat sheet definitely toss 'em in here.
 
Last edited:

Top