I have been trying to reset the root password of MySQL.
I have used to two methods to reset. But I didnt get it.
Following steps are done, But it doesn\'t wo
Below is the process to reset the root user password, when we forgot the root user password or missed to recollect the password provided during installation.
OS - Ubuntu 16.04
MySQL - 5.7
sudo /etc/init.d/mysql stop
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
mysql>use mysql;
mysql>update user set authentication_string=password('root123') where user='root';
mysql>update user set plugin="mysql_native_password" where User='root';
mysql>flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
mysql -uroot -proot123
PFB, the URLs for reference.
https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/ mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists MySQL user DB does not have password columns - Installing MySQL on OSX MySQL fails on: mysql "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded"
Try stopping mysql service
/etc/init.d/mysqld stop
Run the safe executable skipping grants
mysqld_safe --skip-grant-tables &
(the trailing ampersand gets you back to the command line)
Then connect as root without password
mysql -uroot
You'll be in the mysql prompt where you can update root's password.
EDIT: I just saw you're using windows. Ok, then your first method should almost work. Instead of "UPDATE mysql.user" the file should read
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('vikash');
Then run
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqld.exe --init-file=C:\Users\user-name\Desktop\mysql-init.txt
I'm curious about the executable though... all those blank spaces can probably get windows confused. Perhaps it would be easier to create your init file in the same folder as the executable so you just have to run
mysqld.exe --init-file=mysql-init.txt
There might be other executables in there. mysqld-nt, mysqld-safe, etc. If mysqld doesn't work, try the others too.