MySQL multiple ways to change the root password
Under Navicat for MySQL directly execute SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Newpass '); 'll be
Assuming that the compilation installation path is under/USR/LOCAL/MSYQL
To set the environment variable method:
Echo ' Export path= $PATH:/usr/local/mysql/bin ' >>/etc/profile
Source/etc/profile
So MySQL a lot of script files are under/usr/local/mysql/bin
Use these scripts without adding environment variables either it's a CD in the directory and then./a few, or the script name.
Or just use absolute paths:
To log in to the database without an initial password:
/usr/local/msyql/bin/msyql
Method 1: Use the Set password command
If you do not have an initial password and have added an environment variable, use the command MySQL login directly
If it is the way to compile the installation path to/usr/local/mysql then the absolute path/usr/local/mysql/bin/mysql such login
Mysql
mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Newpass ');
Method 2: Use Mysqladmin (set environment variables)
mysqladmin-u root Password "Newpass"
If Root has already set a password, use the following method
mysqladmin-u root password Oldpass "Newpass"
Method 3: Edit the user table directly with update
Mysql-u Root
mysql> use MySQL;
mysql> UPDATE user SET Password = Password (' newpass ') WHERE user = ' root ';
mysql> FLUSH privileges;
This can be done when the root password is lost
Mysqld_safe--skip-grant-tables&
Mysql-u Root MySQL
mysql> UPDATE user SET Password=password ("New password") WHERE user= ' root ';
mysql> FLUSH privileges;
Or
Vim/etc/my.cnf
Find [mysqld] below to join
--skip-grant-tables
Restart database
/etc/init.d/mysqld restart
Log in to the database directly using the MySQL command
UPDATE user SET Password=password ("New password") WHERE user= ' root ';
FLUSH privileges;
\q
And then go in there and/etc/my.cnf--skip-grant-tables or delete the notes.
Then restart the database to log in with the changed password
This article is from the "12252646" blog, please be sure to keep this source http://12262646.blog.51cto.com/12252646/1947388
MySQL multiple ways to change the root password