I will show how to install MySQL server as well as client and how to interact with databases with respective MySQL queries. I worked with debian, hence anyone who reads this blog with debian machine can make use of it effectively.
To install MySQL server, and give a password for further usage
$ sudo apt-get install mysql-server
and its client
$ sudo apt-get install mysql-client
To ensure working of MySQL server is done by,
$ ps -ef | grep mysql
if you get something as below, it is ok to proceed further
root 9646 1 0 12:32 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 9758 9646 3 12:32 ? 00:00:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –user=mysql –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/run/mysqld/mysqld.sock –port=3306
root 9759 9646 0 12:32 ? 00:00:00 logger -t mysqld -p daemon.error
cot 9885 4504 0 12:32 pts/1 00:00:00 grep mysql
$ mysqladmin --version
To log into MySQL monitor to work with databases
$ mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 5.1.49-1 (Debian)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
Hence we are now inside, remember to give same password which you gave during server installation.
$ mysqladmin -u root -p create DUMMY_DATABASE;
mysql> use DUMMY_DATABASE;
mysql> create table audhil_table(sl_no INT NOT NULL AUTO_INCREMENT,name VARCHAR(20) NOT NULL, PRIMARY KEY (sl_no));
mysql> insert into audhil_table (sl_no,name) values (1,"Mohammed Audhil");
. . . .
Atlast my table,
mysql> select * from audhil_table;
| sl_no | name|
| 1 | Mohammed Audhil |
| 2 | Mohammed Afsar |
2 rows in set (0.00 sec)
Ctrl + D
Need to change password of your database
1) Remove existing setup
$ sudo apt-get --purge remove mysql-server mysql-common mysql-client
2) Install it again
$ sudo apt-get install mysql-server mysql-common mysql-client
When prompted for password give new password of your own. Use the same for further activities with MySQL databases.
This may help somebody…