How to install Mysql database

Tags: ,

In this post, we describe the steps of Installing and Starting MySQL

How to Install Mysql On linux

Install Mysql on Ubuntu:

sudo apt-get install mysql-server

Install Mysql on Centos:

sudo yum install mysql-server
/etc/init.d/mysqld start

How to install Mysql on Widows

To install Mysql on Microsoft Windows.  The recommended way is to use the MySQL Installer.

  1. Download MySQL Installer from and execute it.
  2. Choose the appropriate Setup Type for your system. Typically you will choose Developer Default to install MySQL server and other MySQL tools related to MySQL development, helpful tools like MySQL Workbench. Or, choose the Custom setup type to manually select your desired MySQL products.
  3. Complete the installation process by following the MySQL Installation wizard’s instructions. This will install several MySQL products and start the MySQL server.

  4. If you have chosen to configure MySQL as a Windows service during the installation process, which is the default option (see Windows Service for details), the MySQL server will start automatically after the installation process is completed.

  5. Detailed information regarding Windows installation, including alternative installation methods and instructions for troubleshooting, can be found in Installing MySQL on Microsoft Windows.

How to Install Mysql on OS X. 


Connecting to the MySQL Server with the mysql Client

Once your MySQL server is up and running, you can connect to it as the superuser root with the mysql client.

  • On Linux, enter the following command at the command line terminal (for installation using generic binaries, you might need to go first to the bin folder under the base directory of your MySQL installation):

    shell> mysql -u root -p

  • On Windows, click Start, All Programs, MySQL, MySQL 5.x Command Line Client. If you did not install MySQL with the MySQL Installer, open a command prompt, go to the bin folder under the base directory of your MySQL installation, and issue the following command:

    C:\> mysql -u root -p

You are then asked for the root password.  Once you are connected to the MySQL server, a welcome message is displayed and the mysql> prompt appears, at which SQL statements are to be sent to the server for execution:

Here are a few useful things to remember when using the mysql client:

  • Client commands (for example, help, quit, and clear) and keywords in SQL statements (for example, SELECT, CREATE TABLE, and INSERT) are case insensitive.

  • Column names are case sensitive. Table names are case sensitive on most Unix-like platforms, but case insensitive on Windows platforms. Case sensitivity during string comparison depends on the character collation you use. In general, it is a good idea to treat all identifiers (database names, table names, column names, etc.) and strings as case sensitive. 

  • You can type your SQL statements in multiple lines by pressing Enter in the middle of it. Typing a semi-colon (;) followed by an Enter ends an SQL statement and sends it to the server for execution; the same happens when a statement is ended with \g or \G (with the latter, returned results are displayed vertically). However, client commands (for example, help, quit, and clear) do not require a terminator.

To disconnect from the MySQL server, type QUIT or \q at the client: