MySql Command Line Installation Procedure

How To Install Mysql On Linux Fedora Cent OS Ubuntu Linux Redhat Debian through Command Line

There are multiple ways to install mysql on Linux machine

Installing through dnf or yum

If your server is on internet and yum or dnf repository is enabled, then you can install directly by running the below command on linux console.

#dnf install -y mysql-server

mysql-server x86_64 5.1.47-2.fc12
Installing for dependencies:
perl-DBD-MySQL x86_64 4.016-1.fc12
perl-DBI x86_64 1.609-3.fc12
Updating for dependencies
mysql x86_64 5.1.47-2.fc12
mysql-libs x86_64 5.1.47-2.fc12

Installing from RPM

Download the latest mysql-server rpm from

You may need to download and install the dependency packages (mysql-libs, mysql, perl-DBD-MySQL, perl-DBD ) before installing mysql-server

Transfer the downloaded file to the server using winscp or some other file transfer method

#rpm -ivh mysql-libs* mysql* perl-DBD-MySQL* perl-DBD*
#rpm -ivh mysql-server*

Initial Configurations

After installing the mysql using one of the above method, you can start mysql with the default my.cnf settings

#service mysqld start

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system.

/usr/bin/mysqladmin -u root password ‘new-password’

Alternatively you can run:

Default my.cnf file

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

# To allow mysqld to connect to a MySQL Cluster management daemon, uncomment
# these lines and adjust the connectstring as needed.


# If you are running a MySQL Cluster storage daemon (ndbd) on this machine,
# adjust its connection to the management daemon here.
# Note: ndbd init script requires this to include nodeid!

# connection string for MySQL Cluster management tool

Set default root password

By default there will be no password set for mysql admin (root).

Now you can set root password using the below command

#/usr/bin/mysqladmin -u root password ‘new-password’


#mysqladmin -u root password mysqlpasswd

Now you can login to mysql server using the below commands

#mysql -u root -p

Related Articles:
How to create database
How to reset root password


Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.