I installed million MySQL on the CentOS6.4, unable to enter through the root, because the installation, and did not set the root password, there seems to be an initial random password, but do not remember, too troublesome, directly reset the root password.
First, you have to have the operating system root permissions. If you don't have root access to the system, consider the root system and then follow the steps below.
PS: Given root permissions
Method One: Modify the/etc/sudoers file, find the%wheel line, and remove the previous comment (#)
# # allows people in group wheel to run all commands
%wheel all= (All)
The user is then modified to belong to the root group (wheel), and the command is as follows:
After the modification, you can now log in with your Tommy account and then use the command sudo Su-to get root permission to operate.
Method Two: Modify the/etc/sudoers file, locate the root row, and add a row under Root, as follows:
# # Allow ROOT to run no commands anywhere
root all= (All) all
Tommy All=
After the modification, you can now log in with your Tommy account and then use the command sudo Su-to get root permission to operate.
Method Three: Modify the/etc/passwd file, find the following line, modify the user ID to 0, as follows:
Tommy:x:500:500:tommy:/home/tommy:/bin/bash
After the modification as follows
Tommy:x:0:500:tommy:/home/tommy:/bin/bash
Save, with the Tommy account login, the direct access is the root account permissions.
Root is similar to the Safe Mode login system, it is suggested that Pkill MySQL, but I do not recommend Kazakhstan. Because when you execute this command, it can lead to a situation like this:
/etc/init.d/mysqld status
mysqld dead but Subsys locked
So even if you are in Safe mode to start MySQL may not be useful, so generally it is so/etc/init.d/mysqld stop, if you unfortunately first used Pkill, then start to stop again.
After installing MySQL with the RPM package, follow the steps to reset the root password:
Start MySQL:
After successful startup, view the MySQL process information and get the Mysqld_safe installation directory (very critical):
#ps-ef | grep-i MySQL
root 3466 1 0 01:45 pts/1 00:00:00/bin/sh/usr/bin/mysqld_safe--datadir=/var/lib/mysql-- PID-FILE=/VAR/LIB/MYSQL/BSC. Test.pid
mysql 3569 3466 01:45 pts/1 00:00:00/usr/sbin/mysqld---BASEDIR=/USR- Plugin-dir=/usr/lib64/mysql/plugin--user=mysql--log-error=/var/lib/mysql/bsc. Test.err--PID-FILE=/VAR/LIB/MYSQL/BSC. Test.pid
Root 3597 3105 0 01:45 pts/1 00:00:00 grep-i MySQL
You can see the installation location of the Mysqld_safe (blue section above):/usr/bin/
Then execute the command to stop MySQL:
To start MySQL in a safe manner:
#/usr/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &
Wait 5 seconds, and then execute the following statement:
#/usr/bin/mysql-u Root MySQL
Note: MySQL, like the Mysql_safe directory, is:/usr/bin/, this is through "ps-ef | grep-i MySQL "command to get.
When you receive the mysql> prompt, enter:
mysql> Update user Set password = password (' root ') where user = ' root ';
Perform (refresh MySQL system permissions related tables) after carriage return:
Then execute exit exit:
After exiting, use the following command to login to MySQL and try to succeed:
Enter Password by prompt:
However, to perform a view database command error:
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
Solution:
mysql> SET password=password (' root ');
Query OK, 0 rows Affected (0.00 sec)
Query OK, 0 rows Affected (0.00 sec)
+--------------------+
| Database |
+--------------------+
| information_schema |
| MySQL |
| performance_schema |
|
+--------------------+
4 rows in Set (0.00 sec)
PS: If you are using mysqladmin:
# mysqladmin-u root-p Password "test123"
Enter Password: "Enter the original password"