Home Download Ubuntu

Dump all MySQL databases into separate files

Sometimes we need to to dump all databases form a MySQL server. This can be done using the mysqldump utility with the --all-databases switch enabled. In this case mysqldump will dump all databases to the standard output or to a file if explicitly specified. Let’s assume a situation where we want to backup all of the databases from the server, with the possibility to restore only one database at a time. To achieve this, you need to dump all the databases one by one or to use a pre-made script to do the heavylifting for you.  I’ve found a simple solution here: http://soniahamilton.wordpress.com/2005/11/16/backup-multiple-databases-into-separate-files/. I used this script as a starting point, and made some enhancements to it: 1. MySQL username can be specified from the command line (it’s not hardcoded in the file)
2. The script asks for the corresponding MySQL password for security reasons (the password is not echoed or saved anywhere – as you would expect on a Unix systems)
3. The output dir can also be specified from the command line
4. Support for gzipped output files (optional)


Download the dump-all-databases.sh. Make it executable using chmod +x dump-all-databases.sh.
Run it:
./dump-all-databases.sh -u user -o my_backup_dir -z
The command line options are the following:
  • -u – the MySQL user
  • -o – output dir (optional, if not specified the dump files will be placed in current directory)
  • -z – enables the gzipped output (optional)



System requirements

Unix/Linux system with mysql and mysqldump installed, for gzipped output gzip is also required.

Resources: http://carrotplant.com

A different approach to change MySQL root password in Ubuntu Server

The other day I was having a problem with the MySQL server on my Ubuntu machine. After connecting to mysql server in php, I could not select a database. The error was: Access denied for user ''@'localhost' to database foo. I did specify the user being root, but it keept saying I don't have permissions with the user '' (anonymous). Reinstalling mysql didn't do the job. So, let's delete the user ''.

1. Stop the MySQL Server:

sudo /etc/init.d/mysql stop

sudo service mysql stop

2. Start the mysqld:
sudo mysqld --skip-grant-tables &

Press CTRL+C (^C) to be able to enter the new command.
3. Login to mysql server:
sudo mysql -u root mysql

4. Delete the user '':
If you enter the following command:

you will see that the users are different, one being '' and the other root.
Delete the anonymous user:
DELETE FROM mysql.user WHERE user = '';

Update root password (optional, if you know it):
UPDATE user SET Password=PASSWORD('1234') WHERE User='root';

5. Stop mysql server instance:
ps aux | grep mysql

On the second column, you will find the PID (process id) of mysql server. Kill it:
kill 20233

6. Start the usual mysql server:
sudo service mysql start

Resources: ubuntu.flowconsult.at

Change PureFTpd passive ports

If you are behind a firewall and you want to narrow the range of ftp passive ports, run this:

echo "29799 29899" > /etc/pure-ftpd/conf/PassivePortRange

where 29799 29899 is your port range. this configuration is for 50 clients. and yes, you need to have 2 ports for each client.

You might also consider creating a config for max clients:

echo "50" > /etc/pure-ftpd/conf/MaxClientsNumber

Restart pure-ftp-mysql:

/etc/init.d/pure-ftpd-mysql restart

Resources: www.howtoforge.com

List all installed php extensions in Ubuntu

If you need to check what php extensions are installed in command line, you can do this:

sudo dpkg --list | grep php

Resource: serverfault.com

How to control all the actions of transmission client

A uTorrent like cross platform remote control for the Transmission BitTorrent client (transmission-daemon) transmission-remote-java is a cross platform open source remote client to the RPC interface of transmission-daemon, which is part of the Transmission BitTorrent client.

The application is cross-platform and can be downloaded here.

In windows, you can make a shortcut to point to the .jar file. The path should be something like:
"C:\Program Files\Java\jre6\bin\java.exe" -jar "C:\Program Files\transmission-remote-java-0.12.16-1034-bin.jar"

- C:\Program Files\Java\jre6\bin\java.exe is the path to your java sdk installation directory
- C:\Program Files\transmission-remote-java-0.12.16-1034-bin.jar is the path to .jar file