How to connect a mysql server to grafana? - mysql

I'm new on grafana and I need to connect my database (mysql) to it.
I tried to configure the custom.ini file as follow,
I added the next section on database
#################################### Database
####################################
type = mysql
host = localhost:3306
name = grafana (db on my sql server)
user = grafana (user on my sql server)
#### If the password contains # or ; you have to wrap it with triple quotes.
Ex “”"#password;"""
password =***** (password of my sql user)
and the next section on session
#################################### Session ####################################
[session]
provider = mysql (at the beginning)
provider_config = grafana:*******#tcp(localhost:3306)/grafana
provider = mysql (at the end)
When I try to connect to the serve I get this error : “Service init failed: Migration failed err: this authentication plugin is not supported”
I’m new on grafana and I don’t know if I have to set more thinks in the custom.ini
If someone can figure out what is wrong here I will be the happiest man on the world :D
Thanks for the time you spent reading this and a big big thanks to the savior !!

I finally find the problem. The fact is that mysql 8 has some permission faeture which brings a lot of issue for connecting to grafana or read files. So I install mysql 5.7 instead and all was fine !

Related

Failed to connect to database: Error: Can't connect to MySQL server on 'xxxxxx.rds.amazonaws.com' (111)

I am trying to run this command locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title1 = 'CAD GWAS', title2 = 'Coronary Artery eQTL') within R in ubuntu behind a corporate proxy
but having the following persistent issue for three days.
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'locuscompare-us-west-2a.xxxxxx.us-west-2.rds.amazonaws.com' (111)
Warning message:
In rm(config) : object 'config' not found
I have already tried the solutions mentioned in stack overflow, such as installing MySQL, assigning users' privilege, editing bind-address in configuration file, but still do not know how to run it smoothly.
I thought at first it was an issue related to the lacking of MySQL server and AWS account on my device. But, when I use it on my mac with home Wi-Fi, it is working like a charm without any installation and creation of MySQL server and AWS account. However, I still need to use this tool on my work PC because of input data privacy issue.
Does it mean I need to create an AWS account and adjust the network setting in it to access MySQL server on this URL 'locuscompare-us-west-2a.xxxxx.us-west-2.rds.amazonaws.com'? (Sorry that I am very new to AWS and MySQL.)
Please let me know how to run this tool behind a corporate proxy.

Google Cloud Function with Cloud MySQL Authorisation fails ([Errno 111] Connection refused)

I'm trying to connect to my Google Cloud MySQL database through a Google Cloud Function to read some data. The function build succeeds, but when executed only this is displayed:
Error: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") (Background on this error at: http://sqlalche.me/e/e3q8)
Here is my connection code:
import sqlalchemy
# Depending on which database you are using, you'll set some variables differently.
# In this code we are inserting only one field with one value.
# Feel free to change the insert statement as needed for your own table's requirements.
# Uncomment and set the following variables depending on your specific instance and database:
connection_name = "single-router-309308:europe-west4:supermarkt-database"
db_name = "supermarkt-database"
db_user = "hidden"
db_password = "hidden"
# If your database is MySQL, uncomment the following two lines:
driver_name = 'mysql+pymysql'
query_string = dict({"unix_socket": "/cloudsql/{}".format(connection_name)})
# If the type of your table_field value is a string, surround it with double quotes. < SO note: I didn't really understand this line. Is this the problem?
def insert(request):
request_json = request.get_json()
stmt = sqlalchemy.text('INSERT INTO products VALUES ("Testid", "testname", "storename", "testbrand", "4.20", "1kg", "super lekker super mooi", "none")')
db = sqlalchemy.create_engine(
sqlalchemy.engine.url.URL(
drivername=driver_name,
username=db_user,
password=db_password,
database=db_name,
query=query_string,
),
pool_size=5,
max_overflow=2,
pool_timeout=30,
pool_recycle=1800
)
try:
with db.connect() as conn:
conn.execute(stmt)
except Exception as e:
return 'Error: {}'.format(str(e))
return 'ok'
I got it mostly from following this tutorial: https://codelabs.developers.google.com/codelabs/connecting-to-cloud-sql-with-cloud-functions#0 . I'm also using Python 3.7, as used in the tutorial.
SQLAlchemy describes it as not necessarily under the control of the programmer.
For context, the account through which is being connected has the SQL Cloud Admin role, and the Cloud SQL Admin API is enabled. Thanks in advance for the help!
PS: I did find this answer: Connecting to Cloud SQL from Google Cloud Function using Python and SQLAlchemy but have no idea where the settings for Firewall with SQL can be found. I didn't find them in SQL > Connection / Overview or Firewall.
Alright so I figured it out! In Edit Function > Runtime, Build and Connection Settings, head over to Connection Settings and make sure "Only route requests to private IPs through the VPC connector" is enabled. The VPC connector requires different authorization.
Also, apparently I needed my TABLE name, not my DATABASE name as the variable DB_NAME. Thanks #guillaume blaquiere for your assistance!

Connection Database SQL with RStudio

I will start a new project ==> Data visualization by Rstudio. My data into a server phpMyAdmin (SQL Database).
I will use just 4 table. So in this case I should do a link between my database and Rstudio. I found this question on Stackoverflow enter link description here
I tried by this solution, I started by installed the package mySQL, but it return an error:
package ‘mysql’ is not available (for R version 3.2.2)
Knowing that I'm working on PalantirCloud.
Can you please give me a suggestion how can I resolve this problem?
Thank you.
1st grand ALL PRIVILEGES of remote MySQL server to a specific(database) user.
Then run these commands in Rstudio
install.packages("RMySQL")
library("RMySQL")
mydb = dbConnect(MySQL(),user='root',password='query',dbname='bd_test', host='192.X.X.X')
Where -
User = Remote MySQL database username
Password = Remote MySQL database user's password
dbname = Remote database name
And Host = The Remote server URL/IP address

connection refused error in ruby while connecting to mysql database

When I am trying to connect to Mysql database using ruby then I get "Connection to Data Source [2] failed: java.net.ConnectException: Connection refused" error.
I am using RubyMine IDE and I have downloaded Mysql server and workbench and installed mysql gem.
I am not sure if I need to use SSH to connect as I see an option in Rubymine to connect to the Mysql data source.
Here is my code and the error message:
require 'mysql2'
begin
con = Mysql2.new 'localhost', 'root', 'password'
puts con.get_server_info
rs = con.query 'SELECT VERSION()'
puts rs.fetch_row
rescue Mysql2::Error => e
puts e.errno
puts e.error
ensure
con.close if con
end
And the error message is:
Data Source [2]
Connection to Data Source [2] failed: java.net.ConnectException: Connection refused
Could someone help me connect to mysql data source using Ruby on rails and fetch tables and manipulate the data and write back to the database?
Thanks
You don't have to use SSH to connect to a database. That's something you can decide with your application.
You first need to be sure that you can connect to MySQL running on your machine (the MySQL server on localhost). Are you able to do that? Always make sure you can do that; that helps you figure out if the problem is just with connecting to the db or if it's in your code. (Read the RubyMine help for info on how to do that.)
If you can connect using the RubyMine database tool, then you next need to create the database using the rake task "db:create".
Then you're ready to run some code to connect to your db.
Also -- your request is way too broad. You're essentially asking for someone to tutor you on connecting to and working with a database. There are many tutorials out on the web that will step you through connecting to a database and using it. (You might start with the well-known tutorial by Michael Hartl. (A quick search will point you right to it.) If/when you run into a specific problem, come back, describe that specific issue, and then carry on.

Business Objects unable to open database connection to MySQL

We use Business Objects 12 where I work.
BO is trying to pull information from our JIRA Database but I am having some issues getting it to work correctly.
The odbc.ini for BO contains the following:
[LiveJira]
Description = JIRA ODBC Driver
Driver = MySQL3.51
SERVER = ip.of.server.here
PORT = 3306
USER = bouser
Password = password
Database = jiradb
OPTION = 3
SOCKET =
When I try to connect from the server itself using isql LiveJira it connects and I am able to run select statements on the databases.
When the BO client is run on a local laptop it is also able to connect and get the information it needs.
The problem arises when you connect through the BO web interface on the server. The error message is something like:
An error connecting to database: 523 80 (WIS 10901)
I thought for a while it might be to do with the source address of the query, but since isql LiveJira works it does not seem to be address related.
If someone could shed some light on this or knows of an obvious mistake I have made I would be eternally grateful. My searching on google has not provided me with any useful information.