Here are some of the basic functionalities of mysql
1. Installing a mysql Server.
2. Setting up the system environment for mysql.
3. Starting and terminating mysql service.
4. Connecting to mysql server through command line client.
5. Backup mysql db.
6. Restore mysql db.
Installing mysql server.
Users can choose to choose to typical install if just need server to be configured with command line tool. Or choose to install the mysql workbench by choosing either custom or complete installation.
Setting up system environment for mysql.
To set up system environment for mysql follow the following steps.
1. Right click on My Computer and click on properties.
2. In case of XP , from the properties window click on Advance tab.
In case of Windows7 , from the properties window click on advanced system settings.
3. From the advance tab, click Environment variables.
4. From the Environment variables window choose path variable from system variables, and click on edit
5. Now append the mysql path to the path variable. Mysql ll be usually present in “C:\Program Files\MySQL\xyz\bin”
In my case it is “C:\Program Files\MySQL\MySQL Server 5.6\bin”
6. Click OK.
Find the snapshots below for the same.
Advance properties
Environment Variables
path variable
To test the configuration
1. Open RUN command and type ‘mysqld’ and press enter.
( For those who don’t know how to open RUN command
Press Windows key+R ).
2. If a console pops up and closes, system environment has been configured for mysql.
Starting and Terminating mysql service.
To start mysql service
1. Open RUN command, type ‘mysqld’. The mysql service ‘ll be started.
To terminate mysql service
1. Open command prompt.
2. Type in the following commands.
“mysqladmin -u <username> -p shutdown”
Eg: mysqladmin -u root -p shutdown.
3. The console ‘ll prompt for password, enter the password and press enter.
Mysql service ‘ll be terminated.
Connecting to mysql client through command line client
To connect to mysql server,
1. Open command prompt
2. Type in following command
“mysql -h <hostname> -u <username> -p<password> dbname” //not recommended
“mysql -h <hostname> -u <username> -p dbname” // recommended
3. Type in the password. Connection is created if u can see the shell change to mysql.
Below find the snapshots
Mysql Connect
Mysql Connection Success
Backup mysql db
There are different ways to backup MYSQL db. Here i share 2 methods of doing them.
1. Mysql Command Line client.
2. Mysql Query browser.
Backup through Mysql command line client.
To backup only tables and data.
1. Open command prompt.
2. Type in the below commands.
“mysqldump -h <hostname> -u <username> -p --databases dbname1 dbname2 >backup_location”
Usage : “ mysqldump -h localhost -u root -p --databases test1 test2 >c:\backup\backup.sql”
3. The console ‘ll prompt for password. Enter the password, the backup ll be stored at the specified backup location.
To backup Entire database including procedures and triggers.
mysqldump -h <hostname> -u <username> -p --routines --databases dbname1 dbname2 >backup_location
To backup all databases.
mysqldump -h <hostname> -u <username> -p --routines --all-databases >backup_location
Restore Mysql DB.
To restore mysql db.
1. Open command prompt.
2. Type in the following commands
“mysql -h <hostname> -u <username> -p dbname < backupfile.sql”
Enter the password when prompted.
OR
“mysql -h <hostname> -u <username> -p dbname”
Enter the password when prompted.
“source backupfile.sql”
Or
“\. backupfile.sql”
Backup through mysql query browser
Content ll be updated soon.....