mysql

Login:

mysql -u root -ppassword

Show databases:

SHOW DATABASES;

Change database:

USE my_database;

Show tables:

SHOW TABLES;

Remove columns:

ALTER TABLE user DROP username;

Rename table:

RENAME TABLE old_table TO new_table;

Delete table:

DROP TABLE my_table;

Import database

mysql -h host -u user -ppassword database < dump_file.sql

UTF-8

/etc/mysql/my.cnf

[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld]
character-set-client-handshake = false
character-set-server = utf8
collation-server = utf8_general_ci
[mysqld_safe]
default-character-set = utf8

Reset password

mysqladmin -u root password NEWPASSWORD

Resetting a lost MySQL root password

systemctl restart mysql.service
mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD("password") where User='root';
flush privileges;
quit

Create new user in MySQL and give it full access to one database

GRANT ALL PRIVILEGES ON dbTest.* TO 'user'@'hostname' IDENTIFIED BY 'password';

or

GRANT ALL PRIVILEGES ON dbTest.* TO user@localhost IDENTIFIED BY 'password';

Additional uncaught exception thrown while handling exception

Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away:
SELECT lid, location FROM {locales_source} WHERE source = :source AND context
= :context AND ...
sudo vim /etc/my.cnf

Set max allowed packet higher, e. g.:

max_allowed_packet = 100M