Useful MySQL Commands For WordPress

dailydose

(Rishi) #1

Hi :grinning:

This is a mini tutorial on some useful MySQL commands.

#1 Access MySQL Without Root Password

In SSH, we generally use this command to access MySQL:-

mysql -u root -p

But it requires root password to access MySQL. If you don’t want to enter root password, directly access MySQL using:-

mysql --defaults-file=/etc/mysql/debian.cnf

#2 Backup MySQL Database

It is best option to backup MySQL database using SSH in case of heavy sites.

  • To backup database use command:-
mysqldump -u old-user -p old-database > filename.sql

Enter password:- Password of old user.
  • To restore/import database:-
mysql -u new-user -p new-databse < filename.sql

Enter password:- Password of new user.

#3 View MySQL Users

mysql --defaults-file=/etc/mysql/debian.cnf

SHOW processlist;
SELECT User FROM mysql.user;

Please feel free to suggest more commands to add in this list.

#dailydose

Regards
Rishi


List Of Useful Linux Commands Necessary For SSH