Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

How to change MySql root password?

For every database, you should set the root or sa passwords to something other than the default, unless you want to get hacked. For mysql, the system administrator user is called root. You will use the mysqladmin utility from a command line to set the new password.

Syntax:

# mysqladmin -u root password “new_password”

# mysqladmin -u root -h host_name password “new_password”

Example:

# mysqladmin -u root password Pa55w0rD

# mysqladmin -u root -h localhost password linuxgEEks

You need to restart the database server after this change

# /etc/init.d/mysql restart

How To Backup MySQL Database to a file?

Backing up your database is a very important system administration task, and should generally be run from a cron job at scheduled intervals. We will use the mysqldump utility included with mysql to dump the contents of the database to a text file that can be easily re-imported.

Syntax:

# mysqldump -h localhost -u root -pmypassword database_name > dumpfile_name.sql

Example:

# mysqldump -h localhost -u root -pPa55w0rD database110 > backup_file.sql

This will give you a text file containing all the commands required to re-create the database.