Mysql

From wiki.techunit.org
Jump to: navigation, search

Login without password

mysql --defaults-file=/etc/mysql/debian.cnf

Configuration

Allow remote access

sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
service mysql restart

Command lines

Manage databases

# Create Database
CREATE DATABASE database_name;
#Delete Database
DROP DATABASE database_name;

Create users

#Create user with full privileges for all databases from all source IP
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
#Create user with full privileges for one database from LAN 10.0.0.0/24
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'10.0.0.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
#Create user with full privileges for all databases from localhost
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Dump database

mysqldump -u username -ppassword database_name > database_name.sql

Elliot
techUnit's cofounder