I am retiring a couple Linux servers, a web server and a database one.. I made a full database backup using the mysqldump command. Now I wanted to restore one, specific, database from this file on this Windows environment. This particular migration is of a network / WordPress Mu server. My MySQL server is installed on a Windows server, running IIS, and PHP.
Syntax:
open the Windows command prompt, navigate to your MySQL server installation, in my case this is at C:\MySQL\, then navigate to the bin folder where the exe mysql file resides.
mysql -u root -p --one-database destdbname < alldatabases.sql
Substitute dbname with the database name you want to restore, and alldatabases.sql with the name of your full DB backup.
If you would rather just extract the database dump of the single database from the --all-databases dump file, you can do this with sed using this command:
sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql
dbname is replaced with the database name of the database to extract, and alldatabases.sql is the name of your dump file. The result will be saved into the file output.sql.
Example from my environment:
C:\MySQL\bin>mysql -u root -p --one-database wpmu < C:\Users\administrator.A
D\Desktop\all_databases.sql
Enter password: *********
Linux Country
My personal Linux notes, a work in progress, shared online with the world. From intro to pro Linux Administration.
Wednesday, July 1, 2015
Monday, February 2, 2015
What the heck does SUDO mean in Linux?
sudo – short for “substitute user do” – is a command which allows users to run commands with other user’s rights (e.g. root).
Friday, November 1, 2013
Find Machine Name using an IP Address in Windows or Linux
Find Machine Name using an IP Address in Windows or Linux
C:\Users\Homer>nslookup 10.50.2.100
Server: windc.ad.simpson.org
Address: 10.50.2.70
*** windc.ad.simpospn.org can't find 10.50.2.100: Non-existent domain
C:\Users\Homer>nbtstat -a 10.50.2.100
Local Area Connection:
Node IpAddress: [10.12.4.29] Scope Id: []
Host not found.
MyLinux:/ # nslookup 10.50.2.100;
Server: 10.50.2.70
Address: 10.50.2.70#53
** server can't find 175.2.50.10.in-addr.arpa.: NXDOMAIN
MyLinux:/ # smbclient -L 10.50.2.100
Enter root's password:
Connection to 10.50.2.100 failed (Error NT_STATUS_CONNECTION_REFUSED)
MyLinux:/ # host 10.50.2.100
Host 175.2.50.10.in-addr.arpa. not found: 3(NXDOMAIN)
Find largest files
Type the following command at the shell prompt to find out top 10 largest file/directories:
If you want more human readable output try:
Where,
# du -a /var | sort -n -r | head -n 10
If you want more human readable output try:
$ cd /path/to/some/where
$ du -hsx * | sort -rh | head -10
Where,
- du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
- du command -s option : show only a total for each argument (summary).
- du command -x option : skip directories on different file systems.
- sort command -r option : reverse the result of comparisons.
- sort command -h option : compare human readable numbers. This is GNU sort specific option only.
- head command -10 OR -n 10 option : show the first 10 lines.
for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11
This is also a good one ... here this returns the top 40:
find -type f -printf '%s %p\n'| sort -nr | head -40
also see: http://linuxcountry.blogspot.com/2013/05/find-and-sort-all-files-by-size-save.html
Wednesday, October 30, 2013
Using mysqldump - How to back up a MySQL database on Linux with the mysql dump command
You do not need to invoke the mysql command or log into your MySQL server..
From your linux shell command line type:
MyLinuxServer:/ # mysqldump -u root -p databaseName > databaseBackupFileName.sql;
You will be prompted to enter the password next "Enter password:"
Log into a MySQL server
Command:
MyLinuxServer:/ # mysql -u root -p
You will be prompted to enter the password "Enter password:" next
MyLinuxServer:/ # mysql -u root -p
You will be prompted to enter the password "Enter password:" next
Subscribe to:
Posts (Atom)