This tutorial explains how to install MySQL and how to create and query a database. This tutorial is using Ubuntu.
MySQL is a popular relational open source database. Applications can use this database to persist data.
This tutorial covers the installation of MySQL and the usage of the database.
Under Ubuntu you can install MySQL with the following command:
sudo apt-get install mysql-server
The installation procedure allow you to set the root password.
Under Windows download the community edition from http://dev.mysql.com/downloads/. For windows you have installer program available which guides you through the installation process.
MySQL provides the
mysql command line interface for administrative work.
To connect to the MySQL database server use the following command:
# connect as root to MySQL server mysql -u root -p
Once you have created a database on this server you can also connect directory to the database with the following command.
mysql db_name -u user -pmypassword
The default port of the database server is 3306. For example, the Java JDBC connection string to connect to the iotcloud database would be jdbc:mysql://localhost:3306/iotcloud.
mysql command line interface allows you to export your database and import existing backups.
mysqldump command provides the option to create backup of your database, e.g. export your database.
To export the database use the following command.
# creates a dump of the database vogella_blog mysqldump vogella_blog > vogella_blog.sql -p
To import an existing SQL dump file use the following command.
# vogella_blog.sql is your exported SQL file # use option -p to enter your password mysql vogella_blog < /var/www/vhosts/vogella.com/vogella_blog.sql -p
|TRAINING||SERVICE & SUPPORT|
The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.
The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.
Copyright © 2012-2017 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.