using npm any-db and any-db-mysql
var db = anyDB.createConnection('mysql://db_user:921F9DB7pnn0ka777#localhost/db1',function(e,r){if(e){console.log('db.err: '+e);}}); // also tried 127.0.0.1
I should see the console log
db.err: null
But I don't. (I see no error at all).
db.query("SELECT * FROM btns WHERE id='1'").on('row',function(e,r){
console.log('err: '+e);
console.dir(r);
});
The above also prints nothing (not even an error);
In my ssh session mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| db1 |
| test |
+--------------------+
mysql> use db1;
mysql> show tables;
+---------------------------+
| Tables_in_db1 |
+---------------------------+
| btns |
+---------------------------+
The db_user is in database 'mysql', setup like so:
mysql> use mysql;
mysql> update user set password=PASSWORD('921F9DB7pnn0ka777') where user='db_user';
mysql> flush privileges;
mysql> exit;
Why would you expect the first case to ever output anything? You're only logging if the error argument is a truthy value (which null is not).
For the the second case, any-db/any-db-mysql does not emit 'row' events for the streaming (non-callback) version. The streaming version returns a readable stream, so you need to use standard methods for getting data from a readable stream (in object mode):
Listen for 'data' events where the 'data' event handler's argument is a row object.
OR call .read() repeatedly to get row objects
Also for the streaming version, you can listen for an 'error' event to check for errors.
Related
My current installation of mySQL/phpMyAdmin on my ubuntu server is refusing to allow any user to be created with any password I have tried. The error is always:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
I have never had this error before with other installations of mysql, on server and xampp/localhost both. This is a new server installation however.
For example, on the mysql terminal on the command line, any attempt to create a user (with extremely random passwords) fails
mysql> CREATE USER 'ses'#'%' IDENTIFIED BY 'yIO8v3hVai0zosaD';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> CREATE USER 'ses'#'%' IDENTIFIED BY 'yIO8v3hVai0zosaDyIO8v3hVai0zosaDyIO8v3hVai0zosaD';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Same thing with phpMyAdmin
With the following error at the bottom
Warning in ./libraries/dbi/DBIMysqli.class.php#261
mysqli_query(): (HY000/1819): Your password does not satisfy the current policy requirements
Backtrace
./libraries/dbi/DBIMysqli.class.php#261: mysqli_query(
object,
string 'SELECT PASSWORD(\'rSxYcnCcO2fhhKgD\') AS `password`;',
integer 0,
)
./libraries/DatabaseInterface.class.php#244: PMA_DBI_Mysqli->realQuery(
string 'SELECT PASSWORD(\'rSxYcnCcO2fhhKgD\') AS `password`;',
object,
integer 1,
)
./libraries/DatabaseInterface.class.php#1944: PMA_DatabaseInterface->tryQuery(
string 'SELECT PASSWORD(\'rSxYcnCcO2fhhKgD\') AS `password`;',
object,
integer 1,
boolean false,
)
./libraries/server_privileges.lib.php#5055: PMA_DatabaseInterface->fetchSingleRow(string 'SELECT PASSWORD(\'rSxYcnCcO2fhhKgD\') AS `password`;')
./libraries/server_privileges.lib.php#5179: PMA_getHashedPassword(string 'rSxYcnCcO2fhhKgD')
./libraries/server_privileges.lib.php#4176: PMA_getSqlQueriesForDisplayAndAddUser(
string 'test-accountdb',
string '%',
string '',
)
./server_privileges.php#167: PMA_addUser(
NULL,
string 'test-accountdb',
string '%',
NULL,
boolean true,
)
Edit: Added results for the mysql validate_password% variables
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
This is the Validate Password Plugin at work. It was introduced in MySQL 5.6.6.
According to the values returned from the SHOW VARIABLES LIKE 'validate_password%'; you're missing a single special character in your password as indicated by validate_password_special_char_count | 1.
Add a special character such as $ or * to this password yIO8v3hVai0zosaD you'll be able to create the user.
Procedure 1:
Step1: Log in with root user ane and password
Step2: run bellow command in Sql terminal
uninstall plugin validate_password
Step3 : create a new user with whatever password you want
Step4: run bellow command in Sql terminal
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
Step5: Checkout now your username & password by login
Procedure 2:
Add a special character such as $ or * to this password icluding other cases like digit,small case character, uper case character
I am trying to create new user in mysql,
create user 'saravanakumar'#'localhost' identified by 'saravanakumar';
it shows error as,
ERROR 1396 (HY000): Operation CREATE USER failed for 'saravanakumar'#'localhost'
after I read this
ERROR 1396 (HY000): Operation CREATE USER failed for 'jack'#'localhost'
I delete user.But I can't.It shows
mysql> SELECT User FROM mysql.user;
+---------------+
| User |
+---------------+
| root |
| saravanakumar |
| saravanakumar |
| |
| root |
| saravanakumar |
| |
| root |
+---------------+
8 rows in set (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT User FROM mysql.user;
+---------------+
| User |
+---------------+
| root |
| saravanakumar |
| saravanakumar |
| |
| root |
| saravanakumar |
| |
| root |
+---------------+
8 rows in set (0.00 sec)
how can i delete all these user in table and how can i create a single user.What is the root cause of this problem? experts please help me.
ERROR 1396 (HY000): Operation CREATE USER failed for 'saravanakumar'#'localhost'
Does indeed indicate that the user already exists or did exist.
FLUSH PRIVILEGES doesn't delete users.
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT, CREATE USER,
CREATE SERVER, and INSTALL PLUGIN statements. This memory is not released
by the corresponding REVOKE, DROP USER, DROP SERVER, and UNINSTALL PLUGIN
statements, so for a server that executes many instances of the statements
that cause caching, there will be an increase in memory use.
This cached memory can be freed with FLUSH PRIVILEGES.
You are looking for DROP USER.
DROP USER user [, user] ...
http://dev.mysql.com/doc/refman/5.1/en/drop-user.html
Order of buisness would be:
DROP USER 'saravanakumar'#HOSTNAME;
CREATE USER 'saravanakumar'#HOSTNAME [IDENTIFIED BY 'password'];
You will probably need to flush privileges if you use delete from (do not).
Remember: this does not necessarily revoke all the privileges this user may have (like table privileges), you will have to do this yourself - if you don't you may not be able to recreate the user.
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'saravanakumar'#HOSTNAME;
DELETE FROM mysql.user WHERE user='saravanakumar';
FLUSH PRIVILEGES;
CREATE USER 'saravanakumar'#HOSTNAME [IDENTIFIED BY 'password'];
"user" requires you to specify an account name
Syntax for account names is 'user_name'#'host_name'
and
An account name consisting only of a user name is equivalent
to 'user_name'#'%'. For example, 'me' is equivalent to 'me'#'%'.
Additional reading: http://dev.mysql.com/doc/refman/5.1/en/account-names.html
Please read those bug reports for further clarification
http://bugs.mysql.com/bug.php?id=28331
http://bugs.mysql.com/bug.php?id=62255
To me works, I set hostname in UPPERCASE:
DROP USER 'user'#'LOCALHOST'
select User, Host from mysql.user;
Made it clear for me what was happening. I had ended up with the same user under several hosts. Deleting unwanted ones helped!
I am having issues with user privileges in mysql and cloudfoundry.
I was able to insert data into a table and I am trying to insert data into another table and running into the following issue:
mysql> source /home/julien/Documents/donnees/projets/Site-Rencontres/java/src/main/resources/misc/sql/geolocation.sql
ERROR 1142 (42000): INSERT command denied to user 'uEs8kO1Aqdhlr'#'172.30.49.208' for table 'geolocation'
Can anyone please clarify to me how user privileges work on mysql for cloudfoundry?
EDIT 1: Some info:
+-------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for uEs8kO1Aqdhlr#% |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'uEs8kO1Aqdhlr'#'%' IDENTIFIED BY PASSWORD '*A826C24476F83F907DC66060E4C2705D92E151ED' WITH MAX_USER_CONNECTIONS 20 |
| GRANT ALL PRIVILEGES ON `de2474fdd53114ebfbb17b3c236676a28`.* TO 'uEs8kO1Aqdhlr'#'%' |
+-------------------------------------------------------------------------------------------------------------------------------------------+
EDIT 2: Some more info:
mysql> select user();
+-----------------------------+
| user() |
+-----------------------------+
| uEs8kO1Aqdhlr#172.30.49.208 |
+-----------------------------+
1 row in set (0.80 sec)
mysql> select current_user();
+-----------------+
| current_user() |
+-----------------+
| uEs8kO1Aqdhlr#% |
+-----------------+
1 row in set (0.85 sec)
EDIT 3: Yet some more info:
I realized that my sql script was referring the wrong schema (here called dummy):
insert into dummy.geolocation
Removing the "dummy." allowed me to run the script without any error. Why this gave me the above error I am not sure. If any one can explain, that would be useful...
CF provisions both the mysql instance as well as a database. Therefore when you bind a mysql service you actually bind the database to your app. If you notice when vmc tunnelling to the mysql service, it gives you the username/password as well as a key called "name", that is the schema name the tunnel is on. Operations against other schemas would be considered out of the CF account used.
I'm building a website with MySQL. I'm using TOAD for MySQL and suddenly I can't connect to the database as I'm getting an error:
"Too many connections"
Is there any way in Toad for MySQL to view existing connections to be able to kill them or simple close all connections all together?
No, there is no built-in MySQL command for that. There are various tools and scripts that support it, you can kill some connections manually or restart the server (but that will be slower).
Use SHOW PROCESSLIST to view all connections, and KILL the process ID's you want to kill.
You could edit the timeout setting to have the MySQL daemon kill the inactive processes itself, or raise the connection count. You can even limit the amount of connections per username, so that if the process keeps misbehaving, the only affected process is the process itself and no other clients on your database get locked out.
If you can't connect yourself anymore to the server, you should know that MySQL always reserves 1 extra connection for a user with the SUPER privilege. Unless your offending process is for some reason using a username with that privilege...
Then after you can access your database again, you should fix the process (website) that's spawning that many connections.
mysql> SHOW PROCESSLIST;
+-----+------+-----------------+------+---------+------+-------+---------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+------+-----------------+------+---------+------+-------+----------------+
| 143 | root | localhost:61179 | cds | Query | 0 | init | SHOW PROCESSLIST |
| 192 | root | localhost:53793 | cds | Sleep | 4 | | NULL |
+-----+------+-----------------+------+---------+------+-------+----------------+
2 rows in set (0.00 sec)
mysql> KILL 192;
Query OK, 0 rows affected (0.00 sec)
USER 192 :
mysql> SELECT * FROM exept;
+----+
| id |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
mysql> SELECT * FROM exept;
ERROR 2013 (HY000): Lost connection to MySQL server during query
While you can't kill all open connections with a single command, you can create a set of queries to do that for you if there are too many to do by hand.
This example will create a series of KILL <pid>; queries for all some_user's connections from 192.168.1.1 to my_db.
SELECT
CONCAT('KILL ', id, ';')
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE `User` = 'some_user'
AND `Host` = '192.168.1.1'
AND `db` = 'my_db';
I would recommend checking the connections to show the maximum thread connection is
show variables like "max_connections";
sample
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 13 |
+-----------------+-------+
1 row in set
Then increase it by example
set global max_connections = 500;
In MySQL Workbench:
Left-hand side navigator > Management > Client Connections
It gives you the option to kill queries and connections.
Note: this is not TOAD like the OP asked, but MySQL Workbench users like me may end up here
As above mentioned, there is no special command to do it. However, if all those connection are inactive, using 'flush tables;' is able to release all those connection which are not active.
When I issue SHOW PROCESSLIST query, only the first 100 characters of the running SQL query are returned in the info column.
Is it possible to change MySQL config or issue a different kind of request to see complete query (the queries I'm looking at are longer than 100 characters)
SHOW FULL PROCESSLIST
If you don't use FULL, "only the first 100 characters of each statement are shown in the Info field".
When using phpMyAdmin, you should also click on the "Full texts" option ("← T →" on top left corner of a results table) to see untruncated results.
Show Processlist fetches the information from another table. Here is how you can pull the data and look at 'INFO' column which contains the whole query :
select * from INFORMATION_SCHEMA.PROCESSLIST where db = 'somedb';
You can add any condition or ignore based on your requirement.
The output of the query is resulted as :
+-------+------+-----------------+--------+---------+------+-----------+----------------------------------------------------------+
| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |
+-------+------+-----------------+--------+---------+------+-----------+----------------------------------------------------------+
| 5 | ssss | localhost:41060 | somedb | Sleep | 3 | | NULL |
| 58169 | root | localhost | somedb | Query | 0 | executing | select * from sometable where tblColumnName = 'someName' |
See full query from SHOW PROCESSLIST :
SHOW FULL PROCESSLIST;
Or
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
I just read in the MySQL documentation that SHOW FULL PROCESSLIST by default only lists the threads from your current user connection.
Quote from the MySQL SHOW FULL PROCESSLIST documentation:
If you have the PROCESS privilege, you can see all threads.
So you can enable the Process_priv column in your mysql.user table. Remember to execute FLUSH PRIVILEGES afterwards :)
If one want to keep getting updated processes (on the example, 2 seconds) on a shell session without having to manually interact with it use:
watch -n 2 'mysql -h 127.0.0.1 -P 3306 -u some_user -psome_pass some_database -e "show full processlist;"'
The only bad thing about the show [full] processlist is that you can't filter the output result. On the other hand, issuing the SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST open possibilities to remove from the output anything you don't want to see:
SELECT * from INFORMATION_SCHEMA.PROCESSLIST
WHERE DB = 'somedatabase'
AND COMMAND <> 'Sleep'
AND HOST NOT LIKE '10.164.25.133%' \G
SHOW FULL PROCESSLIST
This shows the full processlist with more info.