HOW TO INSTALL AND CONFIGURE MYSQL DATABASE IN LINUX

In this post i will show how to install and configure mysql in linux . And also how to create new mysql database and delete mysql database .

HOW TO INSTALL MYSQL IN LINUX

  • First we will install required package .
[root@deepit ~]# yum install mysql*
Loaded plugins: rhnplugin, security
Repository 'a' is missing name in configuration, using id
This system is not registered with RHN.
RHN support will be disabled.
a                                                                                      | 1.3 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i386 0:5.0.77-3.el5 set to be updated
--> Processing Dependency: perl(DBI) for package: mysql
---> Package mysql-bench.i386 0:5.0.77-3.el5 set to be updated
---> Package mysql-connector-odbc.i386 0:3.51.26r1127-1.el5 set to be updated
--> Processing Dependency: libodbcinst.so.1 for package: mysql-connector-odbc
--> Processing Dependency: unixODBC for package: mysql-connector-odbc
--> Processing Dependency: libltdl.so.3 for package: mysql-connector-odbc
---> Package mysql-devel.i386 0:5.0.77-3.el5 set to be updated
--> Processing Dependency: openssl-devel for package: mysql-devel
---> Package mysql-server.i386 0:5.0.77-3.el5 set to be updated
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
---> Package mysql-test.i386 0:5.0.77-3.el5 set to be updated
--> Running transaction check
---> Package libtool-ltdl.i386 0:1.5.22-6.1 set to be updated
---> Package openssl-devel.i386 0:0.9.8e-12.el5 set to be updated
--> Processing Dependency: zlib-devel for package: openssl-devel
--> Processing Dependency: krb5-devel for package: openssl-devel
---> Package perl-DBD-MySQL.i386 0:3.0007-2.el5 set to be updated
---> Package perl-DBI.i386 0:1.52-2.el5 set to be updated
---> Package unixODBC.i386 0:2.2.11-7.1 set to be updated
--> Running transaction check
---> Package krb5-devel.i386 0:1.6.1-36.el5 set to be updated
--> Processing Dependency: libselinux-devel for package: krb5-devel
--> Processing Dependency: e2fsprogs-devel for package: krb5-devel
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel
---> Package zlib-devel.i386 0:1.2.3-3 set to be updated
--> Running transaction check
---> Package e2fsprogs-devel.i386 0:1.39-23.el5 set to be updated
---> Package keyutils-libs-devel.i386 0:1.2-1.el5 set to be updated
---> Package libselinux-devel.i386 0:1.33.4-5.5.el5 set to be updated
--> Processing Dependency: libsepol-devel >= 1.15.2-1 for package: libselinux-devel
--> Running transaction check
---> Package libsepol-devel.i386 0:1.15.2-2.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================
 Package                            Arch               Version                          Repository       Size
==============================================================================================================
Installing:
 mysql                              i386               5.0.77-3.el5                     a               4.8 M
 mysql-bench                        i386               5.0.77-3.el5                     a               507 k
 mysql-connector-odbc               i386               3.51.26r1127-1.el5               a               159 k
 mysql-devel                        i386               5.0.77-3.el5                     a               2.4 M
 mysql-server                       i386               5.0.77-3.el5                     a               9.8 M
 mysql-test                         i386               5.0.77-3.el5                     a               3.7 M
Installing for dependencies:
 e2fsprogs-devel                    i386               1.39-23.el5                      a               568 k
 keyutils-libs-devel                i386               1.2-1.el5                        a                27 k
 krb5-devel                         i386               1.6.1-36.el5                     a               1.8 M
 libselinux-devel                   i386               1.33.4-5.5.el5                   a               143 k
 libsepol-devel                     i386               1.15.2-2.el5                     a               187 k
 libtool-ltdl                       i386               1.5.22-6.1                       a                37 k
 openssl-devel                      i386               0.9.8e-12.el5                    a               1.9 M
 perl-DBD-MySQL                     i386               3.0007-2.el5                     a               147 k
 perl-DBI                           i386               1.52-2.el5                       a               605 k
 unixODBC                           i386               2.2.11-7.1                       a               832 k
 zlib-devel                         i386               1.2.3-3                          a               100 k
Transaction Summary
==============================================================================================================
Install     17 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 28 M

Downloading Packages:
--------------------------------------------------------------------------------------------------------------
Total                                                                         233 MB/s |  28 MB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libsepol-devel                                                                        1/17
  Installing     : libselinux-devel                                                                      2/17
  Installing     : e2fsprogs-devel                                                                       3/17
  Installing     : zlib-devel                                                                            4/17
  Installing     : keyutils-libs-devel                                                                   5/17
  Installing     : perl-DBI                                                                              6/17
  Installing     : mysql                                                                                 7/17
  Installing     : perl-DBD-MySQL                                                                        8/17
  Installing     : mysql-server                                                                          9/17
  Installing     : krb5-devel                                                                           10/17
  Installing     : libtool-ltdl                                                                         11/17
  Installing     : unixODBC                                                                             12/17
  Installing     : openssl-devel                                                                        13/17
  Installing     : mysql-connector-odbc                                                                 14/17
  Installing     : mysql-bench                                                                          15/17
  Installing     : mysql-test                                                                           16/17
  Installing     : mysql-devel                                                                          17/17
Installed:
  mysql.i386 0:5.0.77-3.el5                                     mysql-bench.i386 0:5.0.77-3.el5
  mysql-connector-odbc.i386 0:3.51.26r1127-1.el5                mysql-devel.i386 0:5.0.77-3.el5
  mysql-server.i386 0:5.0.77-3.el5                              mysql-test.i386 0:5.0.77-3.el5
Dependency Installed:
  e2fsprogs-devel.i386 0:1.39-23.el5     keyutils-libs-devel.i386 0:1.2-1.el5 krb5-devel.i386 0:1.6.1-36.el5
  libselinux-devel.i386 0:1.33.4-5.5.el5 libsepol-devel.i386 0:1.15.2-2.el5   libtool-ltdl.i386 0:1.5.22-6.1
  openssl-devel.i386 0:0.9.8e-12.el5     perl-DBD-MySQL.i386 0:3.0007-2.el5   perl-DBI.i386 0:1.52-2.el5
  unixODBC.i386 0:2.2.11-7.1             zlib-devel.i386 0:1.2.3-3
Complete!
  • Type the below commands to turn mysql on after system reboots .
[root@deepit ~]# chkconfig mysqld on
  • Now start the mysql service .
[root@deepit ~]# service mysqld restart
Stopping MySQL:                                            [FAILED]
Starting MySQL:                                            [  OK  ]
  • This is the configuration file of mysql in linux .
[root@deepit ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~
~
~
~
~
~
~
~
  • Now lets enter the mysql .
  • It will ask you to give password if you have given any .
  • Or else just press Enter . ( to set new password )
[root@deepit ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
  • It will ask “you want to set new root password ? “
  • Type  Y  and hit ENTER .
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n]
  • Now set the password for mysql .
New password:
Re-enter new password:
Password updated successfully!
  • Now it ask you for few settings configuration
  • Type  Y for Yes
  • Type N for NO
Reloading privilege tables..
 ... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y

 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n

 ... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n

 ... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y

 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
  • To enter mysql ( root) Type below command
  • And enter password what you set right now .
[root@deepit ~]# mysql -u root -p
Enter password:
  • After giving the right password , it will show like this .(mysql>)
  • You are in mysql .
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

TO CREATE NEW MYSQL DATABASE IN LINUX

  • Type create database databasename;
mysql> create database deepit;
Query OK, 1 row affected (0.00 sec)
  • To see mysql database just type show databases;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| deepit             |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

TO DELETE MYSQL DATABASES

  • Type drop database databasename;
mysql> drop database deepit;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
  • To quit type front slah and q  (\q)
mysql> \q
Bye
  • To know all commands in mysql type ?
mysql> ?
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
For server side help, type 'help contents'
  • Type below command to stop mysql service in linux
[root@deepit ~]# service mysqld stop
Stopping MySQL:                                            [  OK  ]

 

 

HOW TO GRAPHICALLY DOWNLOAD AND UPLOAD FILES IN WINDOWS AS FTP CLIENT AND LINUX AS FTP SERVER.

VIRUS IN LINUX . LEARN HOW TO INSTALL AND RUN AVG ANTIVIRUS IN LINUX

WHAT’S RUNLEVELS AND HOW TO CONFIGURE RUNLEVELS IN LINUX

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s