Technology blog::Life hacks::Linux::Hardware::Gaming

MySql Administration on Linux

Create your own database server with MySql and Linux

By , 20th July 2010 in Linux

A collection of useful MySql administration snippets for use on Linux Systems. I will be using this as a reference for myself and adding to it from time to time.
 

MySql to Listen on all ports, not just localhost

If you want remote MySql administration on the server just edit the file /etc/mysql/my.cnf, find and comment out the line bind-address = 127.0.0.1: This will allow any computer access to the mysql server, so it should be used with care.

Restart MySql on Linux

You can restart the MySql server by entering the following command:

sudo /etc/init.d/mysql restart

Reset User Password

From time to time it may be necessary to reset the password of a MySql user. Here's how to do it. You will need to log onto the server using an account with root privileges, either on the MySql Administration GUI or through an application such as phpMyAdmin.

You can reset a password by executing the following SQL statement, after updating it to match your given username and password.

  1. UPDATE mysql.USER SET Password=PASSWORD('MyNewPass') WHERE USER='MyUsername';
  2. FLUSH PRIVILEGES;

MySql Backup Database

Using the command line you can easily backup a database to a SQL file.

mysqldump -u <username> -p <password>  database_name > backup-filename.sql

MySql Restore Database

Just as easily as backing up a database to a SQL file, you can restore it back to the server using this command:

mysql -u <username> -p <password> database_name < backup-filename.sql
Further Reading
Comments

There are no comments for this post. Be the first!

Leave a Reply

Your email address will not be published.