Global Linux Knowledge Base…
MySQL – Basic Commands To Know
After Installation of MySQL on Linux System, start it by,
# /etc/init.d/mysql restart or # service mysqld start
Default MySQL configuration file my.cnf is located in /etc/ or in /etc/mysql..
# cat /etc/my.cnf
Generally, root user of MySQL does not have password. To assign password,
# mysqladmin -u root password “LinuxArticles#123″
To login to your MySQL database you need to specify the username, “-p” will ask you the password
# mysql -u root -p
After successfully login, you will be in mysql command line interface.
mysql>
Before starting any project or after fresh installation, we required to create database to store data.
mysql> create database LinuxArticles.org;
After creating databases, list all by,
mysql> show databases;
To use particular database from above list,
mysql> use LinuxArticles.org;
To list all tables of selected DB,
mysql> show tables;
For some reason, if you want to delete created database,
mysql> drop database LinuxArticles.org;
To delete Table from selected Database,
mysql> drop database Table_Name;
Create a new User for Database and grant permission,
mysql> grant all on LinuxArticles.org.* to linuxart@localhost identified by ‘UserPassword@123′;
To take MySQL Database backup,
# mysqldump -u linuxart -p LinuxArticles.org > Backup_File.sql
For some reason, to restore a MySQL Database backup,
# mysql -u linuxart -p LinuxArticles.org < Backup_File.sql
| Print article | This entry was posted by on June 10, 2011 at 4:31 PM, and is filed under All. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |