importing mysql data dump via command line

Recently we had to import a db dump (.sql) file of size 346MB.

Yes there are tweaks to do the same via phpmyadmin to increase post limit, timeout time, upload size etc.

However doing it command line seemed like a better option

Here is the command to import the database

mysql -u your_user -p your_db_name < sql_filename.sql

This works irrespective of the dump size.

Cheers to command line!

How can we reset the autoincrement value of primary key in a mysql table

Now while testing we keep on adding rows to tables. But once we need to put in some real data, the primary key index is no longer the initial value like an empty table.
Suppose we did 30 test entries. Even if we delete them, the next items being added start from index 31.

Here is the fix to make it start from 1 again.

ALTER TABLE tablename AUTO_INCREMENT=0

We can actually set it to any value we require.

Hope it helps. Cheers!

Removing mysql from ubuntu

Below are the steps to remove mysql from ubuntu (it also works when you do not have the mysql root password)

The commands worked fine with Ubuntu LTS 12.0.4 and and mysql 5.5

sudo service mysql stop  #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5.5

Have a great day!

Ref: StackOverflow