w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
MYSQL Query with percentage and other restrictions
Here's how you'd get the city-to-country percentage, by country. I'm OK with telling you this because you were very close with the query you published above. SELECT City.Country, SUM(City.Population) / Country.Population * 100 AS CityPopulationPercentageOFCountryPopulation FROM City INNER JOIN Country ON City.Country = Country.Code GROUP BY City.Country Has your instructor covered inline views, where a subquery is used like a table? I hope so, because that's how you'd include the calculated column with each city. Here's a simplified version with City ID, City Name, City Population, Country Code, and City Population percent: SELECT City.ID, City.Name, City.Country, City.Population, PopPercent.CityPopulationPercentageOFCountryPopulation FROM City INNER JOIN ( SELECT

Categories : Mysql

MYSQL 4 password hashing -> MYSQL 5
"For compatibility purposes, the old_passwords system variable was added, to enable DBAs and applications control over the hashing method. The default old_passwords value of 0 causes hashing to use the 4.1 method (41-byte hash values), but setting old_passwords=1 causes hashing to use the pre-4.1 method. In this case, PASSWORD() produces 16-byte values and is equivalent to OLD_PASSWORD()" http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html I suggest forcing everyone to create a new password, validated via email and a random key, and then store the new passwords with a good method (use something like PHPass or at least bcrypt with salt).

Categories : PHP

Using MySQL PASSWORD function in our app
A few reasons I can think of It's a fast hash (SHA1 I believe) which isn't a good property for password hashes. They might change what hash it uses in a future version of MySQL, breaking your application. They've already done this once, hence the OLD_PASSWORD() function. It doesn't naturally use a salt (although you could use a salt with it if you wanted to by appending it to the password before calling the PASSWORD function) It's non-standard SQL, so if you ever need to port your app to another platform you'll need to come up with a replacement

Categories : Mysql

MySQL password in Django
There is no point in trying to protect that password. Any token in that file that can be used to access the database can be used by anyone else to access the database. That's how shared secret security works. Replace the password by a randomly generated token, and you still have to communicate that token to settings.py, for example. Your better bet is to restrict what computers can connect to your MySQL database using that username and password, adding an additional layer of security. Oh, and making sure no one can access settings.py by securing your webserver and source control systems properly.

Categories : Python

MySQL password() function to PHP
If I understand you correctly there is no need to reproduce PASSWORD() in php do all your validation in one go on mysql side using PASSWORD() in your select like this SELECT `username`,`password`,`id`,`disable_until`,`active` FROM `[x]users` WHERE `username` = 'user1' AND `password` = PASSWORD('password') Here is SQLFiddle demo Unless you use case sensitive collation don't use LCASE() on username column in your statements. It prevents MySql from using an index (indices) if any is defined on that column and cause a full scan on the table. On a side note: your code is vulnerable to sql-injections. Consider to use prepared statements.

Categories : PHP

Cannot Change MySQL password
For windows I did something like this and it worked for me. C:> C:mysqlinmysqld-nt --init-file=C:\mysql-init.txt where mysql-init.txt UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; if you installed with MySQL Installation Wizard then you might need to add this option during the reset --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini"

Categories : Mysql

Forgotten MySQL root password
This time around, the newer version of mysql let me log in with no password. I was able to get it fixed from the command line and get it reset to what I wanted. Tried that multiple times before, so I cannot say I understand what changed now, but it did.

Categories : Mysql

Changing a MYSQL user password by using PHP
You simply have to create a first verification on DB with the username / password entered by the user. If they exist and are good : return true else return false. If true use a location to redirect the user on a page to change the password. If false, display an error ;)

Categories : PHP

good php mysql password hashing
PHP has a nice password hashing API since version 5.5, and it has been backported to be used with versions starting at 5.3.7. Have a look at the documentation and the library you can use. It's superior feature compared to your current solution is to allow upgrade password hashes if you decide to use a better algorithm or improved settings later. example: $store_this = password_hash("rasmuslerdorf", PASSWORD_DEFAULT); $true === password_verify('rasmuslerdorf', $store_this);

Categories : PHP

How to change mysql root password
Try adding sudo in front of the kill and cat commands. Like this: sudo kill `sudo cat /usr/local/mysql/data/FitValet-MacBook-Pro.local.pid` It will then ask you for the root password for your Mac (not mysql). Enter it, and the command should execute without giving you a permission denied error.

Categories : Mysql

SHA-2 for Password storage in MySQL Database?
Don't try to create your own password hashing scheme. Instead use a well known one. Generally there are three options: Bcrypt, Scrypt, and PBKDF2. These are designed by security professionals, and have been around for a long time and have not been broken. Implementations are available for many languages. For the salting question, you have the basic idea right. Usually the salt is stored with the password in the database. The salt is not considered to be a secret, but it should be unique for every user. Bcrypt hashes already contain the salt in itself, so you don't need to worry about that. Related answer in security.se: http://security.stackexchange.com/a/6415/20774 A nice article on the subject of password hashing: http://crackstation.net/hashing-security.htm

Categories : Mysql

How to encrypt a password that is inserted into a MySQL table?
You can use the hash() function to hash your password: $hashed_password = hash( 'sha512', $_POST['password'] ); Then modify your insert statement to insert your hashed password into the database: $sql="INSERT INTO users (username, password, email) VALUES ('$_POST[username]','$hashed_password','$_POST[email]')"; Be aware that your SQL statement is vulnerable to SQL injection since you are using unsanitized user input. For improved security and to protect the integrity of your data, please consider escaping and validating the input before using it in an SQL statement. One way to accomplish this is via mysqli_real_escape_string(): $escaped_username = mysqli_real_escape_string( $con, $_POST['username'] ); $escaped_email = mysqli_real_escape_string( $con, $_POST['email'] );

Categories : PHP

Simulating MySql's PASSWORD() encryption using .NET in Windows 8
I finally found the solution :), I hope it help you: /// <summary> /// Reverse a string /// </summary> /// <param name="s"></param> /// <returns></returns> public static string ReverseString(string s) { char[] arr = s.ToCharArray(); Array.Reverse(arr); return new string(arr); } /// <summary> /// MySQL PASSWORD encryption /// </summary> /// <param name="strMsg"></param> /// <returns></returns> public String HashMsg(String strMsg) { // Convert the message string to binary data. IBuffer buffUtf8Msg = CryptographicBuffer.ConvertStringToBinary(s

Categories : Mysql

Simple encryption (username - password) in JPA, mysql
The password must encrypted in your database... and it's better to not being able to decrypt it ! It means that when encrypting your password you MUST loose some information so that it became impossible to compute the original password from it's encrypted form. (there are many algorithms to do that like md5, ...) Using a salt means that you will append a random string (it is the salt) to the password when the user create it's account. You will store this random string in the user table (just like the encrypted password). To validate the user password at login : find the salt that was generated for the user trying to login. run the encryption algorithm on password+salt compare the result with the encrypted password stored in DB : if they match the password is correct. Here is a link w

Categories : Mysql

mySQL connection string through SSH tunnel without password
MySQL is able to deny logins if they are connecting from the wrong host. Maybe you did not allow ubuntu to connect from localhost? https://dev.mysql.com/doc/refman/5.1/en/connection-access.html

Categories : C#

Access hashed mysql password from python
Firstly I am no python expert, my answer is only aimed for a general approach. Passwords in web applications are usually stored as hashes, not encrypted, this basically makes it harder for someone to get them if your table is compromised. Hashes should be generated as solid as possible. Please do not just a MD5, better use something more secure (from todays perspective) and salt it properly to minimize the risk of rainbow attacks. I wouldn't use the MySQL Password() function for this. The documentation says: The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications. For that purpose, consider MD5() or SHA2() instead. This leaves SHA2(), if you want to hash with MySQL, though don't forget to salt the string befor

Categories : Python

Storing username/password in MySql from Java
The issue is the type mismatch: "getPassword" returns a char[] that needs to be converted to a String to be concatenated in your query. Java will take care of garbage collecting your objects once not used anymore, i.e. not referenced from anywhere so you should not have to worry. Maybe the only security precaution you could take would be to clear the array returned by "getPassword".

Categories : Java

Script to automate recovery of MySQL password
Here is a start: service mysql stop vi /etc/my.cnf # In the server section add skip-grant-tables service mysql start mysql use mysql; insert into user (Host, User, Password) values ('localhost','root',''); update user set Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_Event_priv='Y', Trigger_priv='Y', Create_tablespace_priv='Y' where user='root'; quit; vi /etc/my.cnf # remove skip-grant-tables mysqladmin shutdown service mysql start mysqladmin -u root password XXXXXXXXXX You should recognise the code, it's pretty much what you asked. The missing bits are for you to separate the MySQL commands from the shell commands, or to wrap them as an invocation of mysql: mysql -D mysql ... Also, consider placing the password in a suitably protected file or passing it as

Categories : Shell

Login: email-password match w/ PHP and MySQL
Probably your columns are not called '$username_login' and '$password_login'. $dbusername = $row['$username_login']; $dbpassword = $row['$password_login']; Maybe you just have to omit the $ (in case your columns' names are 'username_login' and 'password_login')

Categories : PHP

Unable to retrieve rows in MYSQL where Password() has been used
Verify that the pass column in the AUTH table is at least 41 characters, or whatever value is returned from: SELECT LENGTH(PASSWORD('foo')) LENGTH(PASSWORD('foo')) ------------------------- 41 This test case demonstrates what happens when pass column in authbad table is not big enough to hold entire password string: CREATE TABLE auth (id VARCHAR(32), pass VARCHAR(41)); // pass column matches length INSERT INTO auth VALUES ('abc',PASSWORD('abc')); CREATE TABLE authbad (id VARCHAR(32), pass VARCHAR(32)); // pass column too short INSERT INTO authbad VALUES ('abc',PASSWORD('abc')); SELECT COUNT(1) FROM auth WHERE pass=PASSWORD('abc'); COUNT(1) ---------- 1 SELECT COUNT(1) FROM authbad WHERE pass=PASSWORD('abc'); COUNT(1) ----------

Categories : Mysql

MYSQL password is just not working...Error 1045
Just create separate MySQL user with proper permissions, like CREATE USER 'admin2'@'localhost' IDENTIFIED BY 'properPass'; GRANT ALL ON *.* TO 'admin2'@'localhost'; if you need new admin.

Categories : Mysql

Generating pbkdf2_sha256 hash of a password by means of MySQL
Usually database systems do not support this kind of hash functions on their own. It would be difficult to write the queries anyway, because the password hashes are not searchable. To verify a password with its hash-value following steps are necessary: Search for the row by username (cannot be done by the hash-value). Return the password-hash from the found row. Extract the used salt and the cost factor from the stored password-hash. Build a new hash-value from the entered password with the same salt and cost factor. Compare the stored hash-value and the new calculated one. That means, you first have to know the stored hash-value, before you can verify the entered password with it. Such a hash function is surely better placed in the development language, than in the database, especiall

Categories : Mysql

How to do a MySQL query with AJAX without revealing db user password?
You make your JavaScript request the information from a PHP script, which checks the user's login cookie (like any other page would) and queries MySQL, returning the information to the JavaScript in whatever form it needs (JSON, usually).

Categories : Javascript

phpMyAdmin Error #1043 Cannot log in to MySQL with root password (OS X 10.8.3)
That is because you need to use the following syntax: mysqladmin -uroot -p***** (command here) I had a similar problem and I solved it by setting a blank password for root and adding this to my config.inc: $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; Then, when I successfully logged in, I changed my root password within the web based GUI. Hope this helps.

Categories : Mysql

Check login string against password (MySQL & JDBC)
con appears to always be null You need to obtain a connection object before you can do con.prepareStatement("SELECT Login, Password from Staff"); There may be other problems in your code, but it's hard to tell which problem you are hitting without a stacktrace Has your Staff table got more than one row in it? Seems like unless the user name that you are loking for isd the first one returned by your SQL statement, then you'll get "Incorrect Log in" . Would n't you be better doing SELECT Login, Password from Staff where Login = UserName ( that isn't syntactically correct in your context but you get the drift ... ) That way, if don;t get a row, then it's an Incorrect Login, and then you just have to compare the hashed values.

Categories : Java

Forgot MySQL server v5.6 password, error timestamp
You should follow this guide here to reset your mySQL password. This must work (tried it, works) so double-check your path information and installation location.EDIT: Just found another method in the comment section of the guide I mentioned above. Seems legit but I didn't try it.

Categories : Mysql

Protect the password when using Mysql in an unattended bash-script
create a file ~/.my.cnf in the home directory of the user running the cron job. make sure is not readable by other users ( chmod 600 ~/.my.cnf ) [client] user=username password=something

Categories : Mysql

Error trying to UPDATE php/mysql code for changing to a new password
A few things wrong here, more than can be put in a comment. I'm sorry, I can't see exactly what your error is, but if you follow point #1, it'll go away. Don't use the mysql library. It is deprecated, and has been removed (finally!) in PHP 5.5. It is only working for you at the moment, because your version of PHP is out of date. You should either be using PDO or MySQLi. Check out this article for information on PDO: http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/ Don't put any variable that's not generated in the script you're looking at into your query, this includes SESSION variables. You just need one flaw in your application, and the user can inject data into the SESSION. Treat every variable as dirty. If you know that it isn't - 100% for certain

Categories : PHP

Change users mysql password with a view to security -- Best Practices
It seems that according to dev.mysql, they recommend just securing the logs rather than sanitizing them. To guard against unwarranted exposure to log files, they should be located in a directory that restricts access to only the server and the database administrator. Replication slaves store the password for the replication master in the master.info file. Retrict this file to be accessible only to the database administrator. Database backups that include tables or log files containing passwords should be protected using a restricted access mode. It would appear that this issue was fixed more elegantly in later versions of MySQL. See: http://dev.mysql.com/doc/refman/5.7/en/password-logging.html In MySQL 5.7, statement logging avoids writing passwords in plain t

Categories : Mysql

mysql Access denied for user 'root'@'localhost' (using password: NO)
I've solved this error. I'm posting this because someone could have encounter the same thing as me. The problem lies with the data source. Apparently something happen during the creation of data source. The password parameter is missing. So I deleted the current data source and created a new one again and the problem is solved.

Categories : Java

Chef: mysql cookbook does not know root's password after I change it using mysqladmin
You need to update the node's attribute to reflect the new password. One way to do that would be to use Knife and the knife-set-attribute plugin. knife set_attribute node mysql.server_root_password yournewpassword Other ways to set attributes can be explored in the Chef attribute docs.

Categories : Mysql

How can ProFTPD read a password encrypted with the MySQL ENCRYPT() function?
ProFTPD does not need to know what the salt is. Per the MySQL documentation, ENCRYPT uses the Unix crypt() implementation of DES. As you pointed out, if no salt is provided, a random salt is chosen. According to the man pages: The returned value points to the encrypted password, a series of 13 printable ASCII characters (the first two characters represent the salt itself). You can verify this for yourself, by running e.g.: SELECT ENCRYPT ('blowfish'); which returns: 201GDb8Aj8RGU If you then run select ENCRYPT ('blowfish', '201GDb8Aj8RGU'); You'll get the same result 201GDb8Aj8RGU. Only the first two characters are used as salt. It becomes a little clearer if you provide your own salt, such as : SELECT ENCRYPT ('blowfish', 'rb'); The returned value is: rbMle0EHJVX

Categories : Mysql

innobackupex restoring changes root and debian-sys-maint password. mysql restart failed
I believe you are using this tool from Percona. Then the only helpful option I can find is --databases. I will assume you do not want to maintain a list of databases in your script, you can build the list dynamically with a command like this: shell > mysql [options] -NBe "SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('mysql', 'information_schema')" You should be able to integrate this call in something like this: shell > innobackupex --databases=`mysql [options] -NBe "SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('mysql', 'information_schema')"` (some extra double quotes may be required, sorry, I do not have access to the tool at this time)

Categories : Mysql

Log in/log out/restrictions
I believe you would need 3 classes: a login form, where the user will authenticate by inserting the credentials and clicking the loginButton a main form, to hold the menu strip, where the other forms could be shown by pressing the menu buttons the child form, which will have a logoutButton and other custom controls (so basically you can derive other child forms from it) In the login form, handle the login button click like this: private void loginButton_Click(object sender, EventArgs e) { if (Authenticated(username.Text, password.Text)) { var mainForm = new MainForm(); this.Visible = false; mainForm.Show(this); } } The main form, add a handler for the form closing event and some handlers for showing the children: public MainForm() { Initializ

Categories : C#

Warning: mysql_query() [function.mysql-query]: Access denied for user 'a8004576'@'localhost' (using password: NO)
Most likely you forgot to call mysql_connect (or include the script that calls it). Consequently, the first call to mysql_query is trying to log in using (incomplete) automatic information and failing. The hint is that the error message is the one typically returned by mysql_connect when invalid credentials are supplied, but it's coming from mysql_query instead.

Categories : Mysql

Hibernate Restrictions in two tables
You need to perform a createAlias (Criteria's way to perform a join). Check this manual. Criteria c = session.createCriteria(User.class, "user"); c.createAlias("user.phone", "phone"); // inner join by default c.add(Restrictions.eq("phone.number", "43523452")); c.list();

Categories : Hibernate

How to add coordinate restrictions to an image
Update the GoLeft and GoRight methods to check the position of the image against the bounds of the view. Assuming self is a UIViewController representing the screen... -(void)GoRight{ CGPoint proposedOrigin = CGPointMake(Ship.center.x +5, Ship.center.y); CGRect screenFrame = self.view.frame; // The ship's origin + width gets the right-most point, // compare this against the main view's width to determine // whether or not it should be moved. if (proposedOrigin.x + Ship.frame.size.width/2.0 < screenFrame.size.width) { Ship.center = proposedOrigin; } else { [self StopRight:nil]; } } I'll leave it up to you to figure out the (easier) GoLeft modifications.

Categories : Objective C

Set artificial memory restrictions
Not aware of any such functionality available, but I would restrict memory consumption (in contrast to usage). So when you start up a test it would have a counter of how many objects/threads it can create and operate on. If the counter value reaches its max allowed value the test waits until one of the threads/objects finishes the job. If you use Parallel class you can set the max degree of parallelisation.

Categories : C#

openERP rules and restrictions
You can not give filter in tree view of object, instead of you can give in action of the object in action you can give like this: <record model="ir.actions.act_window" id="action_employee"> <field name="name">Employees</field> <field name="res_model">Employees.Employees</field> <field name="view_mode">tree,form</field> <field name="domain">[('user_id','=',uid)]</field> </record> Hope this help

Categories : Python

Permutations with order restrictions
I'd say that's a pretty good solution you have so far. There is a few optimizations I see though. Here's my variation: % INITIALIZE NN = 9; L = rand(1,NN-1); while numel(L) ~= NN; L = unique( randi(100,1,NN) ); end % Some bogus constraints constraints = [... L(1) L(2) L(3) L(6) L(3) L(5) L(8) L(4)]; % METHOD 0 (your original method) tic orderings = perms(L); p = size(orderings,1); c = size(constraints,1); toKeep = true(p,1); for perm = 1:p for constr = 1:c idxA = find(orderings(perm,:) == constraints(constr,1)); idxB = find(orderings(perm,:) == constraints(constr,2)); if idxA > idxB toKeep(perm) = false; end end end orderings0 = orderings(toKeep,:); toc % METHOD 1 (your original, plus a few opt

Categories : Performance



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.