It seems that I may have inadvertently loaded the password validation plugin in MySQL 5.7. This plugin seems to force all passwords to comply to certain rules.
I would like to turn this off.
I've tried changing the validate_password_length variable as suggested here to no avail.
mysql> SET GLOBAL validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR 'app' = PASSWORD('abcd');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
I would like to either unload the plugin or neuter it somehow.
Here is what I do to remove the validate password plugin:
Login to the mysql server as root mysql -h localhost -u root -p
Run the following sql command: uninstall plugin validate_password;
If last line doesn't work (new mysql release), you should execute UNINSTALL COMPONENT 'file://component_validate_password';
I would not recommend this solution for a production system. I used
this solution on a local mysql instance for development purposes only.
For mysql 8.0 the command to disable password validation component is:
UNINSTALL COMPONENT 'file://component_validate_password';
To install it back again, the command is:
INSTALL COMPONENT 'file://component_validate_password';
If you just want to change the policy of password validation plugin:
SET GLOBAL validate_password.policy = 0; # For LOW
SET GLOBAL validate_password.policy = 1; # For MEDIUM
SET GLOBAL validate_password.policy = 2; # For HIGH
Building on the answer from Sharfi, edit the /etc/my.cnf file and add just this one line:
validate_password_policy=LOW
That should sufficiently neuter the validation as requested by the OP. You will probably want to restart mysqld after this change. Depending on your OS, it would look something like:
sudo service mysqld restart
validate_password_policy takes either values 0, 1, or 2 or words LOW, MEDIUM, and STRONG which correspond to those numbers. The default is MEDIUM (1) which requires passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters. Changing to LOW as I suggest here then only will check for length, which if it hasn't been changed through other parameters will check for a length of 8. If you wanted to shorten that length limit too, you could also add validate_password_length in to the my.cnf file.
For more info about the levels and details, see the mysql doc.
For MySQL 8, the property has changed from "validate_password_policy" to "validate_password.policy". See the updated mysql doc for the latest info.
To reply to your question: How do I turn off mysql password validation?
Short answer: You can reduce the complexity.
Login to Mysql Client as a root.
set global validate_password.policy = LOW;
set global validate_password.length = 2;
set global validate_password.mixed_case_count = 0;
set global validate_password.number_count = 0;
set global validate_password.special_char_count = 0;
Proceed with create user ...
To disable password checks in mariadb-10.1.24 (Fedora 24) I had to comment out a line in /etc/my.cnf.d/cracklib_password_check.cnf file:
;plugin-load-add=cracklib_password_check.so
then restart mariadb service:
systemctl restart mariadb.service
Uninstall:
mysql> uninstall plugin validate_password;
An uninstalled plugin is not displayed by show plugins;
Install:
mysql> install plugin validate_password SONAME 'validate_password.so';
Disabled by configuration:
[mysqld]
validate_password = OFF
A plugin can be disabled by configuration only if installed.
If you want to make exceptions, you can apply the following "hack". It requires a user with DELETE and INSERT privilege for mysql.plugin system table.
uninstall plugin validate_password;
SET PASSWORD FOR 'app' = PASSWORD('abcd');
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
Bland security disclaimer: Consider, why you are making your password shorter or easier and perhaps consider replacing it with one that is more complex. However, I understand the "it's 3AM and just needs to work" moments, just make sure you don't build a system of hacks, lest you yourself be hacked
You can configure this in mysql configuration file
open /etc/my.cnf file
In this file all the lines which is configuring the password policy make those commented like
#validate-password=FORCE_PLUS_PERMANENT
#validate_password_length=10
#validate_password_mixed_case_count=1
#validate_password_number_count=1
#validate_password_policy=MEDIUM
Uncomment and change the value of the properties you want to change.
Further to the answer from ktbos:
I modified the mysqld.cnf file and mysql failed to start.
It turned out that I was modifying the wrong file!
So be sure the file you modify contains segment tags like [mysqld_safe] and [mysqld]. Under the latter I did as suggested and added the line:
validate_password_policy=LOW
This worked perfectly to resolve my issue of not requiring special characters within the password.
I was having a problem on Ubuntu 18.04 on Mysql. When I needed to create a new user, the policy was always high.
The way I figured out how to disable, for future colleagues who come to investigate, was set to low.
Login to the mysql server as root
mysql -h localhost -u root -p
Set the new type of validation
SET GLOBAL validate_password_policy=0; //For Low
Restart mysql
sudo service mysql restart
For references and the future, one should read the doc here https://dev.mysql.com/doc/mysql-secure-deployment-guide/5.7/en/secure-deployment-password-validation.html
Then you should edit your mysqld.cnf file, for instance :
vim /etc/mysql/mysql.conf.d/mysqld.cnf
Then, add in the [mysqld] part, the following :
plugin-load-add=validate_password.so
validate_password_policy=LOW
Basically, if you edit your default, it will looks like :
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
plugin-load-add=validate_password.so
validate_password_policy=LOW
Then, you can restart:
systemctl restart mysql
If you forget the plugin-load-add=validate_password.so part, you will it an error at restart.
Enjoy !
Things have been a bit different in MySQL 8 (But in fairness, technically for the better). I gave up on trying to remove the password on my local MacOS install. So, I realized that if you can't beat 'em, join 'em!
Here's my quick & dirty solution:
installed MySQL8 via HomeBrew (by default, installs as insecure)
edited my ~/.zshrc (because that's the shell I use. others might use .bash_profile or other)
nano ~/.zshrc
added 2 alias lines
alias mysql='mysql -uroot'
alias mysqladmin='mysqladmin -uroot'
pushed changes by
source ~/.zshrc
So now, rather than worrying about using the -u or -p flags, they're automatically used on mysql or mysqladmin commands.
FYI, this should also work if you DO have a password. You'd simply include the -pPASSWORD in your alias.
(ex: alias mysql='mysql -uroot -pPASSWORD')
Additionally, you could add additional alias lines if you use any other mysql commands.
FYI: DO NOT take these steps on a Production server.
I'd like believe that goes without saying... but, just in case you didn't know better.
Log in to your MariaDB server using the command
mysql -u root
or
mysql -u root -pYOURPASSWORD
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';
and
FLUSH PRIVILEGES;
On some installations, you cannot execute this command until you have reset the root password. You cannot reset the root password, until you execute this command. Classic Catch-22.
One solution not mention by other responders is to temporarily disable the plugin via mysql configuration. In any my.cnf, in the [mysqld] section, add:
skip-validate_password=1
and restart the server. Change the password, and set the value back to 0, and restart again.
For mysql 8.0.7, Go to your mysql directory, and then use:
sudo bin/mysql_secure_installation
to configure the password option.
CREATE USER 'username'#'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'organizer'#'localhost' WITH GRANT OPTION;
CREATE USER 'username'#'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'organizer'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
no need to stop/start mysql
Related
I couldn't figure out what Vtiger was on about when it asked me to set the php.ini file to error_reporting. Even after the error_reporting had been edited to show;
error_reporting = E_WARNING & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
The CRM still persists in telling me it requires resetting, no matter how many time I restarted apache with sudo apachectl restart
Anyway...
After moving on, I managed to get to add the database, which at first, looks straight forward, but beware! There's one more huddle to get over before you can successfully install.
You'll probably receive the command to add:
sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Big headache!!
firstly, Mac OS X 10.13.* running MySQL mysql-5.7.21-macos10.13-x86_64 doesn't own /my.cnf and if like me, you're MySQL file will probably be stored in usr/local/mysql/bin/.
Stop looking, you wont find it anywhere on your Mac...
But there is light at the end of this tunnel...
start up terminal and type:
sudo pico /etc/my.cnf
My.cnf will be empty. Copy and paste this in the file:
[mysqld]
sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Save it (ctrl-x and hit y to accept saving the file) and exit, back into terminal.
Type:
sudo touch /etc/my.cnf
Then run mysql; mysql -u root -p
and check the entry,
SHOW VARIABLES LIKE 'sql_mode';
The result should show the settings you added to my.cnf
Now return to vtiger and continue the installation and it should work :)
For Ubuntu - Run command:
sudo nano /etc/mysql/my.cnf
Add the following part to the bottom:
[mysqld]
sql_mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Run command to restart MySQL Service:
sudo service mysql restart
You will also need to change Database Collation to utf8_general_ci in phpmyadmin.
Done !
If you use mysql on windows, please edit file [mysql.ini]
(sample: C:\wamp64\bin\mysql\mysql5.7.21\mysql.ini) and add below info and then restart mysql service. It's OK
[mysqld]
sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Quick & Dirty:
edit /modules/Install/Utils.php
Block: * Function to check sql_mode configuration
Line 349: return false;
change false to true
YOU DISALBE THE CHECK - OWN RISK
Vtiger CRM 7.3.0
[Windows Manual Installations]
Find My.ini in C:\ProgramData\MySQL\MySQL Server 8.0
Replace
sql-mode="ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
note: MySQL 8.0 does not support NO_AUTO_CREATE_USER (So remove it or sql service would not start)
Fire this query through the root user in MySQL
SET GLOBAL sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
And check if the settings are applied by firing the query as follows
SHOW GLOBAL VARIABLES LIKE 'sql_mode';
You basically have to disable it in utils.php as mysql 8.0 doesnt support NO_AUTO_CREATE_USER.
I have an issue trying to use SELECT INTO OUTFILE and using a directory other than /tmp.
My Linux user is named datam, my MySQL user is lea, and MySQL runs as mysql.
When datam runs mysql -u lea database and tries to do a SELECT INTO OUTFILE with a path of /home/datam/xfers/online/file.csv, I get an error code 13, permission denied. Using /tmp/file.csv works, so I'm fairly confident it is not an issue with permissions within MySQL.
I've added mysql to the datam group and have verified this with:
~$ sudo id mysql
uid=106(mysql) gid=114(mysql) groups=114(mysql),1001(datam)
I have /home/datam/ set as 775 recursively.
If I do sudo -u mysql /bin/bash and go to /home/datam/xfers/online/ and do touch file it writes a file.
What do I need to do to allow mysql to write a file from SELECT INTO OUTFILE?
I believe this is not a duplicate of other questions surrounding this subject, because I've looked at them and followed all of their instructions (setting execute on all directories leading up to the one I want, setting GRANT FILE ON, etc).
MySQL user lea grants:
+-----------------------------------------------------------------------------------------------------------+
| Grants for lea#localhost |
+-----------------------------------------------------------------------------------------------------------+
| GRANT FILE ON *.* TO 'lea'#'localhost' IDENTIFIED BY PASSWORD '*9BB439A3A652A9DAD3718215F77A7AA06108A267' |
| GRANT ALL PRIVILEGES ON `database`.* TO 'lea'#'localhost' |
+-----------------------------------------------------------------------------------------------------------+
This may be caused by mysql user permissions.
As stated here https://dba.stackexchange.com/questions/17029/cannot-output-mysql-data-to-file
To give yourself FILE privilege, do the following:
service mysql restart --skip-networking --skip-grant-tables
mysql <hit enter>
UPDATE mysql.user SET File_priv = 'Y' WHERE user='lea' AND host='localhost';
exit
service mysql restart
The linux user can write a file. But the mysql service may be blocked by apparmor.
Check this file: /etc/apparmor.d/usr.sbin.mysqld.
Add your project folder there:
/usr/sbin/mysqld {
[...]
/home/datam/xfers/online/ r,
/home/datam/xfers/online/* rw
[...]
}
Finally, do a
sudo /etc/init.d/apparmor reload
On modern systems mariaDB & mysql gets installed with systemd support. Among other things, it has this setting in /etc/systemd/system/mysql.service:
Prevent accessing /home, /root and /run/user
ProtectHome=true
That's what stops it from writing in /home.
I found that changing the owner of the directory to the same user as the mysql daemon worked for me.
I have sucessfuly reseted my root password on my localhost xampp. Now when I run the mysql daemon myself ( XAMPP/mysql/bin/mysqld.exe ), I can login with PHPMyAdmin to the MySQL administration with no problem.
However when I run MySQL from XAMPP's Control Panel (the "nice" window with start/stop etc. buttons)
I can't login through PHPMyAdmin anymore - I get error #1045...
This must be something configuration-related? What might be causing this?
Big thanks :)
It seems that mysql daemon in xampp has different default value for the basedir than the my.ini setting file.
So when I've reseted the password without adding the same --defaults-file as XAMPP does when it runs mysqld - I actually reseted a password for a different "workspace".
Thanks to #andy, because his comments led me to the solution :)
So the right way to reset XAMPP's MySQL root user ( on Windows ) is:
1) Stop MySQL with XAMPP Control
2) Prepare init file
Create file called mysql-init.txt directly on C:\ drive and fill it with this content:
#INSERT INTO mysql.user (User,Password) VALUES('root',PASSWORD('root'));
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';
GRANT ALL PRIVILEGES ON * . * TO 'root'#'localhost';
FLUSH PRIVILEGES;
- # is a comment - if you did not have a root user or deleted it by accident - uncomment the first line and comment the second line
These commands create a MySQL user "root" with password "root" and give him/her ALL privileges on everything.
3) Run MySQL daemon with proper params
Run YOUR_XAMPP_INSTALL\mysql\bin\mysqld.exe with these params:
Note the double slashes "\\" instead of single slashes "\"
--defaults-file="c:\\YOUR_XAMPP_INSTALL\\mysql\\bin\\my.ini"
--init-file=C:\\mysql-init.txt
So the whole command for cmd.exe could look like:
c:\YOUR_XAMPP_INSTALL\mysql\bin\mysqld.exe --defaults-file="c:\\YOUR_XAMPP_INSTALL\\mysql\\bin\\my.ini" --init-file=C:\\mysql-init.txt
Of course replace YOUR_XAMPP_INSTALL with the path to your custom xampp install ( very often it is just "xampp" resp. "C:\xampp"). And of course if you are operating on a different drive than "C", change C:\ to WhatEverLetterYouWant:\
4) Try to login on http://localhost/phpmyadmin/
Try to login on http://localhost/phpmyadmin/ with user root and password root, if it does not work, you have done something wrong in the previous 3 steps
5) 4) went fine? => Stop MySQL with XAMPP Control
6) Start MySQL with XAMPP control
7) Try to login again with root/root
8) 7) went fine? => Done :)
References:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
I am trying to set sql_mode in MySQL but it throws an error.
Command:
set global sql_mode='NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLE','NO_AUTO_CREATE_USER','NO_ENGINE_SUBSTITUTION'
Is this not the proper way to set multiple modes?
What are the advantages of setting session and global modes?
Which is preferred?
I have different users trying to update the database with different UNC values and instead of setting the session mode to NO_BACKSLASH_ESCAPES, I though it would make sense to set a global mode for this. Does this make sense?
Please let me know.
Thanks.
BTW, if you set globals in MySQL:
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION';
This will not set it PERMANENTLY, and it will revert after every restart.
So you should set this in your config file (e.g. /etc/mysql/my.cnf in the [mysqld] section), so that the changes remain in effect after MySQL restart:
Config File: /etc/mysql/my.cnf
[mysqld]
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
UPDATE: Newer versions of Mysql (e.g. 5.7.8 or above) may require slightly different syntax:
[mysqld]
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
Make sure that there is a dash between sql-mode not an underscore, and that modes are in double quotes.
Always reference the MySQL Docs for your version to see the sql-mode options.
I resolved it.
the correct mode is :
set global sql_mode="NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Setting sql mode permanently using mysql config file.
In my case i have to change file /etc/mysql/mysql.conf.d/mysqld.cnf as mysql.conf.d is included in /etc/mysql/my.cnf. i change this under [mysqld]
[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
just removed ONLY_FULL_GROUP_BY sql mode cause it was causing issue.
I am using ubuntu 16.04, php 7 and mysql --version give me this mysql Ver 14.14 Distrib 5.7.13, for Linux (x86_64) using EditLine wrapper
After this change run below commands
sudo service mysql stop
sudo service mysql start
Now check sql modes by this query SELECT ##sql_mode and you should get modes that you have just set.
For someone who googling this error for MySQL 8.
MySQL 8.0.11 remove the 'NO_AUTO_CREATE_USER' from sql-mode.
MySQL 5.7: Using GRANT to create users. Instead, use CREATE USER.
Following this practice makes the NO_AUTO_CREATE_USER SQL mode
immaterial for GRANT statements, so it too is deprecated. MySQL
8.0.11: Using GRANT to create users. Instead, use CREATE USER. Following this practice makes the NO_AUTO_CREATE_USER SQL mode
immaterial for GRANT statements, so it too is removed.
Taken from here
So, your sql_mode can be like this:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
Or if you're using Docker you can add next command to docker-compose.yml
mysql:
image: mysql:8.0.13
command: --sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
ports:
- 13306:${MYSQL_PORT}
Copy to Config File: /etc/mysql/my.cnf OR /bin/mysql/my.ini
[mysqld]
port = 3306
sql-mode=""
MySQL restart.
Or you can also do
[mysqld]
port = 3306
SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
MySQL restart.
Access the database as the administrator user (root maybe).
Check current SQL_mode
mysql> SELECT ##sql_mode;
To set a new sql_mode, exit the database, create a file
nano /etc/mysql/conf.d/<filename>.cnf
with your sql_mode content
[mysqld]
sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Restart Mysql
mysql> sudo service mysql stop
mysql> sudo service mysql start
We create a file in the folder /etc/mysql/conf.d/
because in the main config file /etc/mysql/my.cnf
the command is written to include all the settings files from the folder /etc/mysql/conf.d/
For Temporary change use following command
set global sql_mode="NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
For permanent change : go to config file /etc/my.cnf or /etc/mysql/mysql.conf.d/mysqld.cnf and add following lines then restart mysql service
[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Check the documentation of sql_mode
Method 1:
Check default value of sql_mode:
SELECT ##sql_mode //check current value for sql_mode
SET GLOBAL sql_mode = "NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
Method 2:
Access phpmyadmin for editing your sql_mode
Login on phpmyadmin and open localhost
Top on Variables present on the top in menu items and search out for sql mode
Click on edit button to modify sql_mode based on your requirements
Save the changes
Restart server after executing above things
In my case mysql and ubuntu 18.04
I set it permanently using this command
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Append the line after the configuration. See example highlighted in the image below.
sql_mode = ""
Note :You can also add different modes here, it depends on your need
NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
See Available sql modes reference and Documentation
Then save.
After saving you need to restart your mysql service, follow the command below:
sudo service mysql restart
Hope this helps :-)
In my case i have to change file /etc/mysql/mysql.conf.d/mysqld.cnf change this under [mysqld]
Paste this line on [mysqld] portion
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
I just had a similar problem where MySQL (5.6.45) wouldn't accept sql_mode from any config file.
The solution was to add init_file = /etc/mysql/mysql-init.sql to the config file and then execute SET GLOBAL sql_mode = ''; in there.
If someone want to set it only for the current session then use the following command
set session sql_mode="NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Updating this for users Using MAMP PRO {works with MAMP users too}. Because I seem to have got stuck on finding a solution for this, but people recommended I should edit the my.cnf file in the /Applications/MAMP/tmp/mysql/my.cnf folder which does not work because it gets reset after every restart of mysql server.
Referring this document:
The configuration file “my.cnf” of MySQL can be found here:
“/Applications/MAMP/tmp/mysql/my.cnf”. Please note: Editing this file
does NOT work as it will be overwritten every time MySQL is restarted
by MAMP PRO with a “my.cnf” file that is created from the MySQL
template. You must edit this template (menu File > Open Template >
MySQL (my.cnf) > 5.7.30) to modify the MySQL configuration. Manually
adding “my.cnf” files to other locations is not recommended. Every
configuration aspect can be handled with the MySQL template.
Once this is done, add the following in the my.cnf file:
[mysqld]
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Restart the Mysql Server. That should do the trick.
set global sql_mode="NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
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.