MySQL is a relational database server with a great reputation for being fast, consume few resources and adapt very well to the demands of the web. In this article we will show how to connect, from the command line, to a MySQL server, as well as create, list, select and delete a database as well as show information about tables and storage engines
Connect to the mysql server
mysql [-h mysql-server] -u user-name -p[password] [BD]
We encourage using the option -p instead of -ppassword, because the latter is less secure (password is saved in the history)
The default mysql server is localhost
Create database
create schema DB;
Create a database specifying charset and collation
create database DB default character set = UTF8 default collate =utf8_general_ci;
schema is an alias for database command and can be used both interchangeably
See the charset and available collations
show collation;
Or by specifying a specific charset
show collation like 'utf8%';
Delete database
drop schema BD;
List databases
show schemas;
Select a database
use DB;
List tables
show tables;
Show the info for a table
desc table-name;
Show description of a column
show columns from table-name where Field='column-name'
Show the indexes for a table
show index from table-name;
List storage engines
show engines;
Recommended reading
-man mysql
Spanish Video associated
Administering MySQL from the command line, 7 (15)
- How to install MySQL 5.7 on CentOS 7
- How to install MySQL 8.0 in Ubuntu 20.04
- How to install MySQL 8.0 in Debian
- How to install MariaDB on Alpine Linux
- How to install MariaDB on NetBSD?
- MySQL 8.0, change root password
- MySQL server administration – Basic
- Create / modify / delete tables in MySQL
- MySQL user administration
- MySQL – Execute SQL script
- Disable innodb engine in MySQL
- Show MySQL storage engines
- Character set available in MySQL
- Connect to a MySQL server from the LAN
- MySQL can not write in the /tmp dir