In this article I will show you some MySQL commands with examples.

1. MySQL Set Root Password

You can set the mysql root password from command line like this:

mysqladmin -u root password your_password

You can also change mysql root password if you forgot it using this tutorial: How to Recover MySQL Root Password

2. Change MySQL Users Passwords from the command line

mysqladmin -u mysql_username -h mysql_host -p password 'new_mysql_password'

3. How To Connect to Local MySQL Server

This is how you connect to your local MySQL server from the command line:

mysql -u root -p

4. Create a MySQL Database

The following command will create a new MySQL database after you are connected:

create database debiantutorials_db;

5. Backup MySQL Database with mysqldump

Backup a database to a .sql file:

mysqldump -u root -p debiantutorials_db > debiantutorials_db.sql

You can also compress the database with gzip on the fly while you are dumping:

mysqldump -u root -p debiantutorials_db | gzip -v > debiantutorials_db.sql.gz

6. Mysqldump and Skip Table

You want to dump a mysql database with one or more crashed tables and you get an error like this? Continue Reading…

Page 1 of 11