MySQL Database¶
Fire can easily be setup up to run with MySQL
More details of the MySQL database can be found here : https://www.mysql.com/
Install MySQL¶
- Install MySQL on a machine.
- It might be easier to install it on the same machine you are installing Fire on.
Create the DB for Fire in MySQL¶
Create the database for Fire in MySQL
Let us call it
firedb:create database firedb;
Create the User for Fire in MySQL and grant it Permissions¶
Create the User for Fire in MySQL:
CREATE user 'fire'@'%' IDENTIFIED BY 'fire';
GRANT ALL PRIVILEGES ON firedb.* TO 'fire'@'%' WITH GRANT OPTION;
- In
CREATEuser, the user we are creating isfirewho is allowed to access the database from anywhere%and his password isfire. - Next, this user has been granted all
permissions. This, of course can be further restricted based on your use case.
Configure Fire to connect to MySQL¶
Copy
db.properties.mysqlfile into theconfdirectory asdb.properties:cd fire-x.y.z cp conf.orig/db.properties.mysql conf/db.properties
Update the following fields in
conf/db.propertiesbased on the values you used in creating the DB for fire. The below assumes that the database name you created for Fire isfiredb. It also assumes that MySQL has been installed on thesame machineas Fire:# Connection url for the database "firedb" spring.datasource.url=jdbc:mysql://localhost:3306/firedb spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.jpa.database=MYSQL # Username and password spring.datasource.username=fire spring.datasource.password=fire
Install the MySQL Connector Jar file¶
Download the MySQL JDBC driver from http://www.mysql.com/downloads/connector/j/5.1.html
Extract the
JDBC driver JAR filefrom the downloaded file. For example:tar zxvf mysql-connector-java-8.0.11.tar.gz
- just copy the path location for
`JDBC driver JAR file
copy the mysql JDBC driver JAR file to the
fire-server-libdirectory offire-x.y.z:cd fire-x.y.z cp /pathlocation of jdbc jar file/mysql-connector-java.jar fire-server-lib
Create the Tables for Fire in MySQL¶
Create the tables for Fire in MySQL by executing the
create-mysql-db.shscript:cd fire-x.y.z ./create-mysql-db.sh
Troubleshooting¶
MySQL has a problem where one of the default users in the user table is '' @ localhost, which winds up denying all localhost users later in the table. If you are accessing mysql from localhost, assuming Fire and MySQL have been installed on the same machine, then you need to delete this entry in mysql.user table:
select user, host from user where user = ''
#you should see an entry for this and host equals localhost.
DELETE from user WHERE user = '' AND host = 'localhost';
flush privileges;
#this reloads privileges - important step. otherwise you will get access denied error even though you log in with the correct user.
Here is a link on stackoverflow that talks about this: