error on starting grafana service - mysql

I have grafana 4.4.3 on an ubuntu 16.4 LTS which is installed on an vm and its IP is 1.2.3.4 .
I also have a mysql database version 5.0.95 on a CentOS 5.9 and its ip is 5.5.5.5 and mydatabase name is : voip
I want to set mysql as backend for grafana. I'v changed my grafana.ini file like this:
###[database]###
type = mysql
host = 5.5.5.5:3306
name = voip
user = root
password = t#123
###[session]###
provider: mysql
provider_config = `root:t#123#tcp(5.5.5.5:3306)/voip`
I also set my root account to be used as a remote account.
when I want to start grafana-server service, it gives me this error:
Fail to initialize orm engine" logger=sqlstore error="Sqlstore::Migration
failed err: this user requires old password authentication. If you still
want to use it, please add 'allowOldPasswords=1' to your DSN. See also
https://github.com/go-sql-driver/mysql/wiki/old_passwords\n"
what should I do? Did I don anything wrong?

allowOldPasswords error is given when you are using old version of mysql database. to change this you should go to /etc/my.cnf and change oldpasswords = 1 to oldpasswords = 0. next you have to login to your mysql and then enter these commands:
SET SESSION old_passwords=FALSE;
SET PASSWORD FOR 'user_name'#'%'=PASSWORD('<put password here>');
flush privileges;
and at last, restart your mysql service.
hope this post is helpful...

Related

Why mysql odbc configuration not setup in linux?

I have two systems. my first system is ubuntu 16.04. which, work as remote.
and another is centos 6. which, run in virtually. In centos, freeswitch installed. I have to send data from freeswitch to remote system means ubuntu.
on centos, my configuration of odbc.ini as :
[freeswitch]
DRIVER = /usr/lib64/libodbcmyS.so
SERVER = <ipaddress>
USER = root
PASSWORD = <password>
PORT = 3306
DATABASE = freeswitch
OPTION = 67108864
and odbcinst.int as below:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc.so
Setup = /usr/lib64/libodbcmyS.so
FileUsage = 1
Threading = 0
after setup above code.
I have to check odbc connection. for this, command fire as :
isql -v freeswitch
but, it show error as :
[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect
wrong driver description arise this type of error.
I have set proper driver description. wrongly, setup description mention in driver field.
I think you need to change the line
DRIVER = /usr/lib64/libodbcmyS.so
to
DRIVER = MySQL
Thanks.

MySQL does not display during setup of Zabbix

I have issue during Zabbix 2.4-1 installation on ubuntu 14.04.
I used manual from official site, installation was successful, no errors.
Next I created user 'zabbix' with all privileges and database 'zabbix' and imported schema.sql, images.sql and data.sql from Zabbix archive. Then I changed configuration files in /etc/zabbix dir:
zabbix.conf.php
// Zabbix GUI configuration file
global $DB;
// Valid types are MYSQL, SQLITE3 or POSTGRESQL
$DB["TYPE"] = 'MYSQL';
$DB["SERVER"] = 'localhost';
$DB["PORT"] = '3306';
// SQLITE3 use full path to file/database: $DB["DATABASE"] = '/var/lib/zabbix/zabbix.sqlite3';
$DB["DATABASE"] = 'zabbix';
$DB["USER"] = 'zabbix';
$DB["PASSWORD"] = 'root';
// SCHEMA is relevant only for IBM_DB2 database
$DB["SCHEMA"] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
zabbix-server-mysql.conf
...
# dbc_dbtype: type of underlying database to use
# this exists primarily to let dbconfig-common know what database
# type to use when a package supports multiple database types.
# don't change this value unless you know for certain that this
# package supports multiple database types
dbc_dbtype='mysql'
# dbc_dbuser: database user
# the name of the user who we will use to connect to the database.
dbc_dbuser='zabbix'
# dbc_dbpass: database user password
# the password to use with the above username when connecting
# to a database, if one is required
dbc_dbpass='root'
...
I start it with apache server. When I go to localhost/zabbix I see Zabbix Installer. On step 3 it's necessary to configure DB connection. So, here is a problem:
As you see, in select list is only PostgreSQL, so, I can't connect to database (mysql server is running) and go to the next step.
Your PHP doesn't support MySQL at the moment. You need to install some php-mysql* package and then restart your webserver.
Your php package for mysql is not there so that it will not show while zabbix setup installation
install php-mysql package to resolve this error
#apt-get install php7.0-mysql
and then restart apache
#systemctl restart apache2
I had the same problem installing Zabbix 4.0 on Ub
So I ran
apt install php libapache2-mod-php php-mysql
sudo service apache2 restart
it works for me

Unable to connect to remote mysql server using unixodbc, libmyodbc

I'm a little green at this, and I hope the issue I'm having is a simple one...edit: new information at bottom
I need to make a connection to a remote mysql (Amazon RDS) database.
After following a few tutorials, I have unixodbc and libmyodbc installed and configured on the client, but when I try to connect via isql, I get the error
[08S01][unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[ISQL]ERROR: Could not SQLConnect
The most confusing part about this error is that I'm not trying to connect to a local database, but rather to a remote one. I do not have a mysql.sock file on the client...this isn't the issue though is it?
I'm sensing a configuration error but I'm just not sure what it could be.
If I run odbcinst -j then the output is:
DRIVERS............: /etc/unixODBC/odbcinst.ini
SYSTEM DATA SOURCES: /etc/unixODBC/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini
The content of /etc/unixODBC/odbcinst.ini is:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc5.so
Setup = /usr/lib64/unixODBC/libodbcmyS.so
UsageCount = 5
[MySQL ODBC 515 Driver]
Description = ODBC 5.515 for MySQL
DRIVER = /usr/lib64/libmyodbc5-5.1.5.so
SETUP = /usr/lib64/unixODBC/libodbcmyS.so
UsageCount = 3
Please note that I had to make up this configuration myself, I did a find for libmyodbc* and found these two .so files, thus set up a driver for each of them. A search for libodbcmyS* yields:
/usr/lib64/unixODBC/libodbcmyS.so.1
/usr/lib64/unixODBC/libodbcmyS.so
/usr/lib64/unixODBC/libodbcmyS.so.1.0.0
So, I don't know what else that configuration could be.
The content of /etc/unixODBC/odbc.ini is:
[target_db]
Driver = MySQL
Server = [servername.com]
Port = 3306
Database = [databasename]
Option = 2
User = [username]
Password = [password]
I've tried different options in "Driver", changing it from MySQL, to MySQL ODBC 515 Driver, to the path to the .so file (eg: /usr/lib64/libmyodbc5.so) and all yield the same result.
I'm running:
odbcinst -i -d -f /etc/unixODBC/odbcinst.ini
Followed by:
odbcinst -i -s -l -f /etc/unixODBC/odbc.ini
Followed by:
odbcinst -s -q
Which prints out the name of my connection, ie [target_db]
Then, I try the connect:
isql -v target_db user password
or just
isql -v target_db
and get the error shown above.
Anyone happen to know what I'm doing wrong here? Thanks a bunch-
EDIT:
Wanted to mention that I'm able to connect to the database from this server using the mysql command line tools.
I installed a local mysql database, and I'm able to connect to this using isql. It seems to be ignoring my odbc.ini file entirely, i have to enter a name with the command, ie isql -v test-database, but it still tries to connect to localhost despite my settings.
I feel as though I've tried everything but will keep at it and will post if i find a solution.
You could try to connect using the ip of your server instead of the dns entry on the "Server" line of odbc.ini.. Have you verified the driver is installed with phpinfo()?
Try to set the environment variable ODBCINI with the path of your odbc.ini file.
Keep in mind that the odbc.ini file you point to must be "write-accessible" by the user that is running the program (i.e. the user must have permissions to write in this file).
chmod g+w .odbc.ini did it for me since we run the DB with ORACLE-Start and the crs-User seems to be in charge

using unixodbc driver to connect to mysql, default database not working

I have my unixodbc odbc.ini configure file like this:
[test]
Driver = /usr/local/lib/libmyodbc5-5.1.8.so
Description = Connector/ODBC 5.1.8 Driver DSN
SERVER = 127.0.0.1
PORT = 3306
USER = root
Password =
DATABASE = test
OPTION =
SOCKET =
And the problem is that it will not use the database as specified above, which is 'test'.
What I have to do is to manually execute a direct sql to change to database and run my query:
SQLExecDirect(stmt, "USE test", SQL_NTS);
SQLExecDirect(stmt, "SELECT * FROM mytable", SQL_NTS);
Any idea on how should I get rid of the 'USE test' which is a mysql command.
Why is unixodbc not setting 'test' as the default db since it's already specified in the conf file?
As on windows the driver manager (unixODBC in this case) only acts on the Driver tag, all other entries in the DSN are up to the driver to interpret. It doesn't notice there is a database= entry and know by magic that in this driver it should execute a "USE" command, and for another call SQLSetConnectAttr( SQL_ATTR_CURRENT_CATALOG ).
On my copy of the MySQL driver, it certainly uses the database= entry. However, I would check that 1. The copy of the driver you are using is built to use the unixODBC lib to access the shared config file (libodbcinst.so), or the driver is reading it directly, and is reading the same ini file as unixODBC. Possibly check with strace to see what ini is opened after the driver is loaded. Maybe try setting ODBCINI=/path/to/your/odbc.ini
[test]
Driver = /usr/local/lib/libmyodbc5-5.1.8.so
Description = Connector/ODBC 5.1.8 Driver DSN
SERVER = 127.0.0.1
PORT = 3306
USER = root
Password =
**DATABASE** = test
**OPTION** = **3**
**SOCKET** =
and can change options between 1,2 too

How do I retrieve my MySQL username and password?

I lost my MySQL username and password. How do I retrieve it?
Stop the MySQL process.
Start the MySQL process with the --skip-grant-tables option.
Start the MySQL console client with the -u root option.
List all the users;
SELECT * FROM mysql.user;
Reset password;
UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[username]';
But DO NOT FORGET to
Stop the MySQL process
Start the MySQL Process normally (i.e. without the --skip-grant-tables option)
when you are finished. Otherwise, your database's security could be compromised.
Unfortunately your user password is irretrievable. It has been hashed with a one way hash which if you don't know is irreversible. I recommend go with Xenph Yan above and just create an new one.
You can also use the following procedure from the manual for resetting the password for any MySQL root accounts on Windows:
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to
the Services manager:
Start Menu -> Control Panel -> Administrative Tools -> Services
Then find the MySQL service in the list, and stop it. If your server is
not running as a service, you may need to use the Task Manager to force it to stop.
Create a text file and place the following statements in it. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
The UPDATE and FLUSH statements each must be written on a single line. The UPDATE statement resets the password for all existing root accounts, and the FLUSH statement tells the server to reload the grant tables into memory.
Save the file. For this example, the file will be named C:\mysql-init.txt.
Open a console window to get to the command prompt:
Start Menu -> Run -> cmd
Start the MySQL server with the special --init-file option:
C:\> C:\mysql\bin\mysqld-nt --init-file = C:\mysql-init.txt
If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing each root account password.
You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:
C:\> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --init-file=C:\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager:
Start Menu -> Control Panel -> Administrative Tools -> Services
Find the MySQL service in the list, right-click on it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.
You should now be able to connect to MySQL as root using the new password.
An improvement to the most useful answer here:
1] No need to restart the mysql server
2] Security concern for a MySQL server connected to a network
There is no need to restart the MySQL server.
use FLUSH PRIVILEGES; after the update mysql.user statement for password change.
The FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
The --skip-grant-options enables anyone to connect without a password and with all privileges. Because this is insecure, you might want to
use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
from: reference: resetting-permissions-generic
Do it without down time
Run following command in the Terminal to connect to the DBMS (you need root access):
sudo mysql -u root -p;
run update password of the target user (for my example username is mousavi and it's password must be 123456):
UPDATE mysql.user SET authentication_string=PASSWORD('123456') WHERE user='mousavi';
at this point you need to do a flush to apply changes:
FLUSH PRIVILEGES;
Done! You did it without any stop or restart mysql service.
While you can't directly recover a MySQL password without bruteforcing, there might be another way - if you've used MySQL Workbench to connect to the database, and have saved the credentials to the "vault", you're golden.
On Windows, the credentials are stored in %APPDATA%\MySQL\Workbench\workbench_user_data.dat - encrypted with CryptProtectData (without any additional entropy). Decrypting is easy peasy:
std::vector<unsigned char> decrypt(BYTE *input, size_t length) {
DATA_BLOB inblob { length, input };
DATA_BLOB outblob;
if (!CryptUnprotectData(&inblob, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &outblob)) {
throw std::runtime_error("Couldn't decrypt");
}
std::vector<unsigned char> output(length);
memcpy(&output[0], outblob.pbData, outblob.cbData);
return output;
}
Or you can check out this DonationCoder thread for source + executable of a quick-and-dirty implementation.
If you have root access to the server where mysql is running you should stop the mysql server using this command
sudo service mysql stop
Now start mysql using this command
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Now you can login to mysql using
sudo mysql
FLUSH PRIVILEGES;
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Full instructions can be found here http://www.techmatterz.com/recover-mysql-root-password/
Login MySql from windows cmd using existing user:
mysql -u username -p
Enter password:****
Then run the following command:
mysql> SELECT * FROM mysql.user;
After that copy encrypted md5 password for corresponding user and there are several online password decrypted application available in web. Using this decrypt password and use this for login in next time.
or update user password using flowing command:
mysql> UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[username]';
Then login using the new password and user.
After MySQL 5.7.6 and MariaDB 10.1.20 (currently in 2022) you can:
Update a mysql user password having access to root user
ALTER USER 'some_user_name'#'localhost' IDENTIFIED BY 'a_super_secure_password';
Update mysql root user
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
List all users
select user from mysql.user;
IF you happen to have ODBC set up, you can get the password from the ODBC config file. This is in /etc/odbc.ini for Linux and in the Software/ODBC folder in the registry in Windows (there are several - it may take some hunting)
Save the file. For this example, the file will be named C:\mysql-init.txt.
it asking administrative permisions for saving the file
Although a strict, logical, computer science'ish interpretation of the op's question would be to require both "How do I retrieve my MySQL username" and "password" - I thought It might be useful to someone to also address the OR interpretation. In other words ...
1) How do I retrieve my MySQL username?
OR
2) password
This latter condition seems to have been amply addressed already so I won't bother with it. The following is a solution for the case "How do i retreive my MySQL username" alone. HIH.
To find your mysql username run the following commands from the mysql shell ...
SELECT User FROM mysql.user;
it will print a table of all mysql users.