Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Created September 11, 2015 15:16
Show Gist options
  • Save rushipkar90/7251fc7782612f30de9c to your computer and use it in GitHub Desktop.
Save rushipkar90/7251fc7782612f30de9c to your computer and use it in GitHub Desktop.
MySql Commands
mysql -u root -p
Enter server root password ( #cat /root/.my.cnf)
CREATE DATABASE databasename;
CREATE USER username@localhost;
SET PASSWORD FOR username@localhost= PASSWORD("password");
grant all privileges on databasename.* to Databaseuser@localhost identified by 'password';
FLUSH PRIVILEGES;
mysql> show databases; --------------- To view all the databases present on the server.
mysql> use databasename ------------- To make the changes under particular DB
mysql> show tables; ------ To view all the tables from specifc DB
mysql> describe tablename; ------ To view the content of specific table under the particular DB ( for e.g. mysql> describe wp_users;)
To reset the wp-admin password of wordpress site from SSH
==============
mysql> SELECT ID, user_login, user_pass FROM wp_users;
+----+------------+------------------------------------+
| ID | user_login | user_pass |
+----+------------+------------------------------------+
| 1 | fargo | $P$BEIZhgIHXUYoUK3o6.TgJ8yWkqmnr7/ |
+----+------------+------------------------------------+
===============
UPDATE (wp_users) SET user_pass="specify the new pasword in MD5 format" WHERE ID = (specify the id of the user which we need to change the password); ------ To update/Edit particular table entry
For e.g UPDATE (wp_users) SET user_pass = MD5(‘”change12@”‘) WHERE ID = (1);
Mysqldump one table - Taking dump of only one table
=============
Dump - mysqldump db_name table_name > table_name.sql
restore - mysql -u -p mydatabase < table1.sql
=============
To import the .sql file into the specific database
======================
mysql Username_database name < Username_database name.sql (less than sign is for importing the database)
======================
To dump database in .sql file
==================
mysqldump datbasename > Filename.sql
==================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment