How to install Mysql database
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.
- Download MySQL Installer from http://dev.mysql.com/downloads/installer/ and execute it.
- 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.
-
Complete the installation process by following the MySQL Installation wizard’s instructions. This will install several MySQL products and start the MySQL server.
-
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.
-
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.
-
The recommended way for installing MySQL on OS X is to use the OS X installer package. See Installing MySQL on OS X Using Native Packages on how to download and run the installer package, and how to start the MySQL server afterward.
-
Detailed information regarding installation on OS X can be found in Installing 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
, , , . If you did not install MySQL with the MySQL Installer, open a command prompt, go to thebin
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:
1 2 3 4 5 |
Welcome to the MySQL monitor. Commands end with ; or \g. ... Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> |
Here are a few useful things to remember when using the mysql client:
-
Client commands (for example,
help
,quit
, andclear
) 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 anEnter
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
, andclear
) do not require a terminator.
To disconnect from the MySQL server, type QUIT
or \q
at the client:
1 |
mysql> QUIT |