Connect to SphinxQL through Linux command-line - mysql

I am trying to connect to SphinxQL server through Linux command-line this way:
> mysql -P 9306
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
My Sphinx config file has 2 listen entries:
listen = 9312
listen = 9306:mysql41
searchd daemon is running:
> ps ax | grep searchd
10727 ? S 0:00 /usr/local/sphinx/bin/searchd
10728 ? Sl 0:00 /usr/local/sphinx/bin/searchd
Regular search queries work perfectly:
> /usr/local/sphinx/bin/search StackOverflow | more
Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/usr/local/sphinx/etc/sphinx.conf'...
index 'test1': query 'StackOverflow ': returned 2 matches of 2 total in 0.009 sec
displaying matches:
1. document=1788212, weight=1797
id=1788212
...
So, what I am doing wrong? How can I get access to SphinxQL console?
Any hint will be appreciated. Thanks in advance!

the 'mysql' client, will totally ignore the -P param, if it detects mysql is running on a unix-socket. So really even though you ask for the sphinxQL port, you are connecting to mysql
Use
mysql -P9306 --protocol=tcp
to tell the client to ignore the socket.
Pro Tip:
mysql -P9306 --protocol=tcp --prompt='sphinxQL> '
which serves as a useful ongoing reminder you are connected to sphinx not mysql :)

Works for me:
mysql -P 9306 -h 0

I ran into this recently. I was able to get in to Sphinx via the mysql shell by commenting out the listen configuration that didn't specify MySQL. This may not work for you, if you still need to get to searchd via the API.

Related

MySQL CLI: unknown option: enable-cleartext-plugin

This question has been asked a couple of times out here, but I'm not able to enable cleartext plugin. I'm using mySQL CLI to access an RDS(Engine version: 5.7.26) instance using the command
mysql -h $RDSHOST -u <Username> --password=$TOKEN --enable-cleartext-plugin --port=3306 --ssl-ca=<path to pem file>
I get the following error:
mysql: unknown option '--enable-cleartext-plugin'
I installed mySQL by running yum install curl mysql -y. But in the logs I see maria-db being installed, is there something wrong out here. Thanks in advance.
Note: If you're using a MariaDB client, the --enable-cleartext-plugin option isn't required.
According to the article found here: https://aws.amazon.com/premiumsupport/knowledge-center/users-connect-rds-iam/
tl;dr: do not use the mariadb client to connect to an AWS RDS instance using IAM Authentication.
Here's a quick answer for your issue, and another for the one you'll hit after removing the flag:
You are definitely running a mariadb client, you can confirm it with mysql --version.
On the paper mariadb always enable plugins, thus does not provide the enable-cleartext-plugin flag on the client.
However —after losing several hours yesterday on the same issue— it appears that the client does not even use the cleartext plugin when you try to authenticate against a AWS RDS instance with IAM Authentication (tested with mariadb 10.3 and 10.5 clients against a MySQL 8.0.23 server).
In the end you must use the 'official' mysql client for this usecase. Some linux distributions provide this client through another package like Percona-Server (which is the case for Arch Linux and Exherbo at least).
For me I had to re execute this then I could login with the special user:
ALTER USER 'myuser' IDENTIFIED WITH AWSAuthenticationPlugin as 'RDS';

How do I unlock user in mysql without execute sql query?

I have installed some production, there is mysql embedded instance in production. Installation is successful, but when I tried to connect mysql instannce, I got following error messages.
[root#MiWiFi-R3D-srv bin]# ./mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/msql.sock' (2)
[root#MiWiFi-R3D-srv bin]#
[root#MiWiFi-R3D-srv bin]#
I can sure mysql instance is running.
aam 13390 1 0 08:01 ? 00:00:00 /bin/sh /opt/SIU_MANAGER/mysq /bin/mysqld_safe --defaults-file=/var/opt/SIU_MANAGER/mysql/my.cnf --pid-file=/var/opt/AAM/mysql/data/my.pid --ledir=/opt/AAM/mysql/bin --basedir=/opt/AAM/mysql --tmpdir=/var/opt/AAM/mysql/tmp/ --datadir=/var/opt/AAM/mysql/data --character-sets-dir=/opt/AAM/mysql/share/charsets/ --lc-messages-dir=/opt/AAM/mysql/share --lc-messages=en_US --user=bin
aam 13578 13390 0 08:01 ? 00:00:02 /opt/AAM/mysql/bin/mysqld --defaults-file=/var/opt/AAM/mysql/my.cnf --basedir=/opt/AAM/mysql --datadir=/var/opt/AAM/mysql/data --plugin-dir=/opt/AAM/mysql/lib/plugin --tmpdir=/var/opt/AAM/mysql/tmp/ --character-sets-dir=/opt/AAM/mysql/share/charsets/ --lc-messages-dir=/opt/AAM/mysql/share --lc-messages=en_US --log-error=MiWiFi-R3D-srv.err --pid-file=/var/opt/AAM/mysql/data/my.pid
root 17786 11762 0 08:27 pts/1 00:00:00 grep --color=auto mysql
I did little research. Mysql offical solution is that execute sql in mysql, but if I can not connect sql
I can not execute any sql.
Mysql offical solution https://dev.mysql.com/doc/mysql-security-excerpt/5.7/en/account-locking.html
When used with ALTER USER, these clauses specify the new locking state
for an existing account. In the absence of either clause, the account
locking state remains unchanged.
This is mysql version.
[root#MiWiFi-R3D-srv bin]# ./mysqladmin -V
./mysqladmin Ver 8.42 Distrib 5.7.25, for linux-glibc2.12 on x86_64
[root#MiWiFi-R3D-srv bin]#
How do I unlcok root user?
PS: I have root privillage of OS.
Thank you for answer me.
It looks like, for some reason, your communication socket for MySQL is being created in /tmp, and is presumably being deleted by some process that periodically cleans up /tmp.
You can get it back by restarting the mysqld process through whatever means is appropriate to your system.
You should also move it out of /tmp, perhaps into /var/run.

How to re-setup Database configurations in Icinga2 server?

I am using ubuntu 16.04 and mysql DB ,i configured DB for icinga2 server and i created separate user in database.
somedays back i deleted that user from db now i am not able access icingaweb2 UI,
Getting below error while trying to access to the link.
All configured authentication methods failed. Please check the system log or Icinga Web 2 log for more information.
I followed the below link to install icinga2 server
Please Help.
I resolved the issue by re-creatinging a setup token in in the Icinga Web 2 by using bellow command
sudo icingacli setup token create
i got some error's while creating setup token and it is easily resolved by using [1]: https://monitoring-portal.org/index.php?thread/40111-icingacli-does-not-work/
If you still have access to the MySQL DB you should do a backup first of your icinga2 DB.
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]
Then purge MySQL or follow the guide on how to reset your root password
After you have access to the DB again if you purged MySQL use this to bring your data back in.
mysqldump -u [username] -p [password] [databasename] < [backupfile.sql]
If you only lost your password to IcingaWeb2 or now have access to MySQL then create a MD5 based BSD password algorithm:
openssl passwd -1 "password"
Note: The switch to openssl passwd is the number one (-1) for using the MD5 based BSD password algorithm.
Insert the user into the database using the generated password hash:
````
INSERT INTO icingaweb_user (name, active, password_hash) VALUES ('icingaadmin', 1, 'hash from openssl');
Source

Is Cloud SQL 2nd gen. compatible with mysqldump commands?

I try to dump my Cloud SQL instance database from my local computer.
I know I should use gcloud commands but in the project I will use it would be a real pain to rewrite all the mysqldump instructions.
I can connect to Cloud SQL via the MySQL client, but when I try to use mysqldump I get the following:
mysqldump --databases testdb -h 130.211.xxx.xxx -u root -p > testdump.sql
mysqldump: Got error: 1227: Access denied; you need (at least one of) the SUPER privilege(s) for this operation when using LOCK TABLES
And of course CloudSQL doesn't support SUPER privileges... :/
Does anyone know if there's a way around?
Yes it accepts it, but you must first, use the cloud_sql_proxy, and have the right permissions. Also this is not in the documentation as of the moment, neither as a warning nor as an official method. Still using an intermediary bucket for dumps is not of my liking.
In Mac OS with latest mysqldump as of moment (posted of an example of the problems I encountered might vary with os and mysqldump version)
mysqldump --column_statistics=0 -h 127.0.0.1 -u <user> -p <db> --set-gtid-purged=OFF> <dumpFile>
// this is because I use the tcp connection sample for the cloud sql proxy
mysql -h 127.0.0.1 -u <user> -p -D <database> < DBs/mysqldump100519.sql
According to their documentation, seems you have 2 options.
The first, which you do not like is to use a gcloud command.
The second, use RESTful API to access the service which is, under the hood, used by gcloud commands. You may use the same request from inside you code. Take a look here.

Login to MySql using Linux terminal not responding

Im trying to login to MySQL in localhost using the root username (default) with no password entering the following command:
mysql -u root -h localhost
I dont get the 'mysql>' and it does not fail so im left with the terminal letting me type but it does not execute any commands (inside or outside of mysql). I also tried using -p and leaving the password blank and I get the same result
Check the following (taken from http://dev.mysql.com/doc/mysql-linuxunix-excerpt/5.5/en/unix-postinstallation.html )
Use mysqladmin to verify that the server is running. The following commands provide simple tests to check whether the server is up and responding to connections:
shell> bin/mysqladmin version
shell> bin/mysqladmin variables
The output from mysqladmin version varies slightly depending on your platform and version of MySQL, but should be similar to that shown here:
shell> bin/mysqladmin version
mysqladmin Ver 14.12 Distrib 5.5.29, for pc-linux-gnu on i686
...
Server version 5.5.29
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 14 days 5 hours 5 min 21 sec
Threads: 1 Questions: 366 Slow queries: 0
Opens: 0 Flush tables: 1 Open tables: 19
Queries per second avg: 0.000
If you are unable to run that command then your installation is either not complete (follow the instructions starting at the top of the page ) or you do not have permission as the user to execute the mysql program.