MySQL server administration – Basic

MySQL

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

YouTube Video

Administering MySQL from the command line, 7 (15)

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.