How to access MySQL/MariaDB from terminal server

Natan Cabral
Mar 26, 2021

--

A lot of people ask me about faster access and consult.

# Login with client and password
$ mysql -u username -p

# List all databases in MySQL:
mysql> SHOW DATABASES;
+ — — — — — — — — — — +
| Database |
+ — — — — — — — — — — +
| my_project |
| information_schema |
| mysql |
| performance_schema |
| sys |
+ — — — — — — — — — — +

# Use the database ‘my_project’ for all later commands
mysql> use my_project;

# List all tables in db ‘my_project’
mysql> show tables;

# Show the schema of ‘table_name’ within ‘my_project’
mysql> describe table_name;

# Consult
mysql> select * from table_name where 1

Very simple, right?!

--

--

Natan Cabral
Natan Cabral

Written by Natan Cabral

Full Stack Developer | Dev Java, Node.js, TypeScript, React.js, Vue.js, Express.js, Next.js, Rest API, Laravel, Databases, MongoDB, Unix distro and Open Source

No responses yet