User Tools

Site Tools


Sidebar






newpage

linux:databases:mysql

This is an old revision of the document!


mySQL

Server Setup | Security | Performance Tuning | …



mysqlcheck

Run mysqlcheck to fix SQL index/.. errors and clean the caches once in a while. this can be used as a weekly cronjob, the output is sent by mail:

 mysqlcheck -A -r --host=${HOST}  --user=root --port=3308 \ 
 --password=${PASSWD} | mail -s '[SQL Server] mycheck complete' $EMAILADDI


mysqldump

dump a database to a .sql file. there are many parameters. check 'man mysqldump'

–opt is important to fix encoding!

 mysqldump --opt --host=127.0.0.1 --default-character-set=utf8 --user=root --password=${PWD} $DB > $FILE


mysql import

works by piping an sql file into the 'mysql' command:

 mysql --host=127.0.0.1  -u root --port=$PORT --password=${DBPWD} ${DBNAME} < ${MYSQLDUMP_FILE}


execute mysql command

any sql statement can be executed in commandline and scripts by using '-e' param:

 mysql --host=127.0.0.1  -u $DBUSER --password=${DBPWD} --port=$PORT \ 
 -e "CREATE DATABASE ${DBNAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"


linux/databases/mysql.1322932183.txt.gz · Last modified: 2011/12/03 18:09 by tkilla