Table of Contents
MySQL General Info
Initial setup
Recommended to run following script after starting mysqld (service mysqld start & chkconfig mysqld on)
/usr/bin/mysql_secure_installation
Dump database to sql file
/usr/bin/mysqldump -u #username# -p --add-drop-database #database# > #dump_file.sql#
Restore Dump file
To restore mysql database from a dump file, just type the command below:-
mysql -u #username# -p #database# < #dump_file.sql#
Move location of data files
To move the location of the diles where MySQL stores its database files, you will need to edit the my.cnf file in /etc. The default location of the database files is /var/lib/mysql/, but a better location is under a specific data area. If this data area is on its own partition, it would be possible to alter the mount properties to allow more efficient database transactions.
Shutdown mysqld (service mysqld stop), move all the files in your current data directory (/var/lib/mysql/) to the new location (/data/db/).
In your /etc/my.cnf file change datadir to point to the new directory:-
[mysqld] datadir=/data/db
Note that the socket which mysql communicates over is still in /var/lib/mysql:-
[root@hosting3 db]# ls -l /var/lib/mysql total 86160 srwxrwxrwx 1 mysql mysql 0 May 12 14:51 mysql.sock