2011-02-09

MySQL (RHEL5)

chkconfig mysqld on
/etc/init.d/mysqld start
Login mysql
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'passpass'; (passpass is the password you use to login)
DROP USER 'user2'@'localhost'
GRANT ALL ON *.* TO 'user1'@'localhost'; (wildcard % is allowed for * match)
USE mysql
UPDATE user SET password=PASSWORD("passpass") WHERE User='user1';
FLUSH PRIVILEGES;

Modify MySQL configuration file (/etc/my.cnf for Fedora-based linux; /etc/mysql/my.cnf for Debian-based linux), so it looks like this:
[client]
max_allowed_packet=1024M
[odbc]
max_allowed_packet=1024M
[mysqld]
max_allowed_packet=1024M
slave_transaction_retries=128
default-storage-engine=INNODB
datadir=/mnt/MD_1000/mysql
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306


Open port 3306 for remote administration:
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
Or if the only allowed client (e.g. your web server) is 10.5.1.3, then:
/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

Save iptables rules:
service iptables save

Backup/dumping with limited rows (e.g. to build a sample database from a large one)
mysqldump -u [username] -p [databaseName] --where="true limit 100" > dump.sql

No comments: