Mysql commands ..

The following is a list of MySQL useful commands.

# To setup root password (first execution)
mysqladmin -u root password 'new_password'
 
# To login to MySQL
mysql -u root -p
 
# To create a database
create database dbname;
 
# To change database
use dbname;
 
# To create a user and assign to it permission to database
# Grant permission only from localhost connections
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
 
# Grant permission on all connections
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
 
# Manage MySQL export
# Copy all db1 content to /backup-db/db1 folder
mysqlhotcopy db1 /backup-db/db1
 
# Create a DB dump to a file
mysqldump db1 > db1_dump_db.sql -u root -p
Hope this help

No comments:

Post a Comment