Archive for the ‘mysql’ Category

Backup mysql configs and database

sudo tar cvfvz /backup/mysql_conf.tgz /etc/mysql sudo sh -c ‘mysqldump -u root -p -A –events > /backup/backup_db.sql’ sudo tar cvfvz /backup/mysql_data.tgz /var/lib/mysql

Mysql create new database and user

CREATE DATABASE testdatabase;   CREATE USER ‘testuser’@’localhost’ IDENTIFIED BY ‘testpassword’;   GRANT ALL PRIVILEGES ON testdatabase.* TO ‘testuser’@’localhost’;

mysql export a single table

mysqldump -u -p db table1 table2 table3

Mysql check corrupted tables

mysqlcheck -c databasename -uyourusername -pyourpassword