The purpose of this article is to give the full information to setup and use mysql server on raspberry pi Raspbian. For many Internet of Things systems, we need to setup the Raspberry Pi as a server which always needs the database functionality. To make the article be more specific, let give an example using mysql to implement a practical function as following: use Raspberry Pi to scan the around ibeacons and analyse its signal strength to detect the weak signal ibeacons.We This article will walk you through following items:
1. How to install the mysql-server on raspberry pi Raspbian.
2. How to make a new mysql account and grant permission for it.
3. How to essentially use the mysql command lines to Create/Read/Update/Delete (CURD) databases, tables, records.I recommend that you should have your Pi be power-on and ready to go.

Step 1: Install mysql-server

The Raspbian image out of the box does not contain the mysql server. That the reason why if you start entering commands to use mysql for checking status do anything else, it will throw an error as following:

That is because the mysql-server package is not installed. Here is the command to install mysql-server:

Read the installation log and make sure everything goes right.

Step2: Create new user for mysql server

We usually thing that the root user is already there and have all permissions to access anywhere, but actually the root user doesn’t exist as super man in mysql until you make it happen. Now let try using mysql with root user on local host:

The root user is denied to access mysql server because we did not grant permission for it. Here is the way to give permissions for the root user.

That’s it, now you can start to use mysql with the root user.

Step3: essentially use the mysql command lines

– Create database and delete database

$> mysql -u root -e “create database pibeacon”

– Create a table (AND DELETE TABLE)

Follow command line syntax here:http://www.tutorialspoint.com/mysql/mysql-create-tables.htm
$> mysql -u root -p
mysql> CREATE DATABASE pibeacon;
Query OK, 1 row affected (0.01 sec)

mysql> SHOW DATABASES;

How to setup MySQL server on raspberry pi
Tagged on:         
Share This

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Subscribe

To download the latest tutorials

You have successfully download

Enter Email To Download

Join our mailing list to receive the latest Application for free from IoTBreaks.

You have Successfully Subscribed!

flash Raspbian to SDCard

Enter Email To Download

Join our mailing list to receive the latest Application for free from IoTBreaks.

You have Successfully Subscribed!

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!