How to show users of database with Erlang? - ejabberd

I can't query in internal database, with console
ejabberdctl debug
Erlang/OTP 20 [erts-9.3] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10]
Eshell V9.3 (abort with ^G)
(ejabberd#localhost)1>
Is it possible to display the registered users on the ejabberd server?

Yes, you can execute this command in the shell, for example:
$ ejabberdctl registered_users localhost
user1
user2
user3
user8
user9

Related

MySQL User Permission Errors using Sqitch on Ubtunu

I am running into what I think is a very easy issue to fix, I am just out of possible ideas.
I have a brand new Ubuntu 14.04 x64 server. I just installed MySQL. Not Apache, php or phpMyAdmin, just plain MySQL.
I have run through mysql_secure_installation and created a password for my root user.
I then put my root password in the /etc/mysql/my.cnf file under the [client] section.
I can run mysql -u root and get to the MySQL console just fine.
However, if I run sqitch deploy I get:
Access denied for user 'root'#'localhost' (using password: NO)
Sqitch is pointing to:
[target "database name_v1"]
uri = db:mysql://root#/databasename_v1
[engine "mysql"]
target = db:mysql://root#/databasename_v1
EDIT
It turns out the problem was with Sqitch and my configuration. Sqitch is a Perl application and needed the perl module MySQL Config in order to read the my.cnf file and access the database.
It turns out the problem was with Sqitch and my configuration. Sqitch is a Perl application and needed the perl module MySQL::Config in order to read the my.cnf file and access the database.
If you are using -v to get MySQL version, here's your answer : mysql -V
-v is for verbose output.
See this thread for more details.
"mysql -v" command line error(linux/ubuntu)
There are multiple root users in mysql. They are in the format user#remote.
You can check if the user password is set for all of those by running the query select Host, User, Password from mysql.user where User="root";
The output should show something like:
+--------------+----------+-------------------------------------------+
| Host | User | Password |
+--------------+----------+-------------------------------------------+
| localhost | root | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| testvm | root | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| 127.0.0.1 | root | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
If the password is empty, set it via mysqladmin.
From here on, your connection to mysql, whether coming from localhost, or coming from the hostname will be allowed to login.

mysql connection terminates when i logoff from the remote server

I had written a script that connects to the local mysql server every 6 seconds and checks if there is any data in the table .if there is data it runs some php commands and then deletes that data from the table. I logged into my remote server(Shared hosting) through ssh and then copied the script and executed it using command "nohup ./script.sh 0<&- &>alert.log &" so that it runs in background and writes all the output to alert.log file. my problem is that when i log in to the server through SSH and execute the script it runs perfectly , but when i log out from server its not running . when i check the alert.log file after it is showing error "cannot connect to local mysql server". any solutions ??
this is the code
while true
do
res=($(mysql -u root -p123456 --skip-column-names -Dtest -e "select id from temptab"))
if [[ "$res" > 0 ]];then
del=`mysql -u root -p123456 -Dtest -e "delete from temptab;" `
now="$(date +'%d/%m/%Y:%H.%M.%S')"
for ((i=0; i < ${#res[#]}; i++))
do
php -n /var/lib/mysql/trigger.php ${res[$i]}
echo "[$now]:Trigger called with videoid ${res[$i]}"
done
fi
sleep 6
done
and this is the sample output
cat nohup.out
X-Powered-By: PHP/5.4.20
Content-type: text/html
{"multicast_id":8864856209398719411,"success":2,"failure":1,"canonical_ids":0,"results":[{"message_id":"0:1385797766832904%4f0c6467f9fd7ecd"},{"error":"InvalidRegistration"},{"message_id":"0:1385797766832901%4f0c6467f9fd7ecd"}]}81Inserted police info
[30/11/2013:00.49.26]:Trigger called with videoid 65
/etc/bashrc: line 14: whoami: command not found
/etc/bashrc: line 20: grep: command not found
/etc/bashrc: line 59: dircolors: command not found
./alert.sh: line 15: php: command not found
[30/11/2013:07.50.27]:Trigger called with videoid 70
./alert.sh: line 15: /ramdisk/php/54/bin/php54: No such file or directory
[30/11/2013:09.09.52]:Trigger called with videoid 71
screen is what you need. There are plenty of tutorials on google on screen usage.
I suggest to move your code into a crontab even that will run every X minutes (5 minutes, or anything else you like) rather than have your user run it during a live session.
Just place the PHP script inside a call to cron, login, and run crontab -e then add:
*/5 * * * * /home/username/phpscript.php
You could try to run your script like:
/path/to/script.sh </dev/null &>/home/yourname/alert.log &
disown
I
finally i got the solution .... i was using /usr/bin/php to call my php files but .....when i edited it to /usr/bin/php.orig it started working........... but what is that php.orig...?? #all thanks

MacOS Mountain Lion Users command dscl

I am running dscl . -list /Users in the Terminal. I see some users have an _ before the name e.g. _mysql
This "seems" to prevent me setting up a mysql user. Whe I try to set up a mysql user either as root or any other user account I have I get a message that the mysql user already exists. I do not have a Standard or Admin user called "mysql" when I run the dscl command other than the _mysql user.
What does the _ before mysql mean please?
Note the RecordName entry for that account:
$ dscl . -read /Users/_mysql
AppleMetaNodeLocation: /Local/Default
GeneratedUID: FFFFEEEE-DDDD-CCCC-BBBB-AAAA0000004A
NFSHomeDirectory: /var/empty
Password: *
PrimaryGroupID: 74
RealName:
MySQL Server
RecordName: _mysql mysql
RecordType: dsRecTypeStandard:Users
UniqueID: 74
UserShell: /usr/bin/false
This account's primary name is _mysql, but it has mysql as an alias.
Solution: don't create a mysql account, use the one that's already there.

Documents visible but "doesn't exist"

I have been developing my application from a dev sandbox and want to push the reference data from "dev" to "prod". I thought I'd succeeded by executing the following commands:
On my OSX dev machine:
cbbackup http://127.0.0.1:8091 ~/couchbase-reference-data -b reference_data -u username -p password
Again on my OSX dev machine:
cbrestore ~/couchbase-reference-data http://prod.server.com:8091/ -u password -p password
Now when I go to the admin console on production I see this:
Looks good at this point. However, if I click any of the "Edit Document" button things go tragically wrong:
Any help would be GREATLY appreciated!
UPDATE:
I've noticed that now when I run the cbrestore command I get the following errors:
2013-06-03 16:53:48,295: s0 error: CBSink.connect() for send: error: SASL auth exception: aws.internal-ip.com:11210, user: reference_data
2013-06-03 16:53:48,295: s0 error: async operation: error: SASL auth exception: aws.internal-ip.com:11210, user: reference_data on sink: http://prod.server.com:8091/(reference_data#127.0.0.1:8091)
error: SASL auth exception: aws.internal-ip.com:11210, user: reference_data
This reminds me that I think what I did was copy the ~/couchbase-reference-data directory to the production environment and then ran the cbrestore from there. I have just done that now and get the following confirmation:
[####################] 100.0% (189/189 msgs)
bucket: reference_data, msgs transferred...
: total | last | per sec
batch : 1 | 1 | 16.1
byte : 36394 | 36394 | 585781.0
msg : 189 | 189 | 3042.1
done
After this process, however, the problem still exists in the same manner as described before.
UPDATE 2
I decided to delete, re-create, and re-import the bucket on production. All steps completed and I still have the same error but I'm wondering if the LOG file has any interesting information in it:
The things that stand out as interesting to me are:
The loading time was "0 seconds" ... as much as I'd like to believe that it may be a little too quick? It's not a ton of data but still.
The "module code" is named 'ns_memecached001' ... is that an issue? Memcached? I did double check that I set this up as a couchbase bucket. It is.
It seems as if your destination server is not OS X, but e.g. Linux. Here you have to use the "rehash"-extra-option.
Backup your data on your dev machine (using cbbackup)
Copy the data to your prod machine
Restore the data with the -x rehash=1 flag: (using cbrestore -x rehash=1)

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.