-
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
-
You will find that password in '/root/.mysql_secret'.
-
-
You must change that password on your first connect,
-
no other statement but 'SET PASSWORD' will be accepted.
-
See the manual for the semantics of the 'password expired' flag.
-
-
Also, the account for the anonymous user has been removed.
-
-
In addition, you can run:
但是坑爹的是压根没在/root下找到.mysql_secret文件,好把,百度,使用无需验证的方式,修改my.cnf
-
[mysqld]
-
port=3306
-
character- set-server = utf8
-
explicit_defaults_for_timestamp= 1
-
skip-grant-tables=1
重启mysql
-
[root@cdh etc] # service mysql restart
-
Shutting down MySQL.. SUCCESS!
-
Starting MySQL. SUCCESS!
-
[root@cdh etc] #
登录上mysql,然后切换到mysql
-
[root@cdh etc]# mysql
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 1
-
Server version: 5.7.3-m13 MySQL Community Server (GPL)
-
-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-
-
Oracle is a registered trademark of Oracle Corporation and/or its
-
affiliates. Other names may be trademarks of their respective
-
owners.
-
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-
mysql> use mysql
-
Reading table information for completion of table and column names
-
You can turn off this feature to get a quicker startup with -A
-
-
Database changed
接下来就是重点了修改密码,需要修改两次,一次authentication_string,一次 password
-
mysql> UPDATE user SET authentication_string=PASSWORD( "123456") WHERE user='root';
-
Query OK, 4 rows affected (0.00 sec)
-
Rows matched: 4 Changed: 4 Warnings: 0 mysql>
-
update user set password=password('123456') where user='root';
-
Query OK, 4 rows affected (0.00 sec)
-
Rows matched: 4 Changed: 4 Warnings: 0
然后把之前的配置skip-grant-tables=1去掉,重新启动mysql
-
[root@cdh etc]# /etc/init.d/mysql restart
-
Shutting down MySQL.. SUCCESS!
-
Starting MySQL. SUCCESS!
-
[root@cdh etc]# mysql -proot -p
-
mysql: [Warning] Using a password on the command line interface can be insecure.
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 1
-
Server version: 5.7.3-m13
-
-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-
-
Oracle is a registered trademark of Oracle Corporation and/or its
-
affiliates. Other names may be trademarks of their respective
-
owners.
-
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-
mysql>
最后还是要再执行下修改密码的语句的
-
mysql> use mysql
-
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
-
mysql> SET PASSWORD = PASSWORD( '123456');
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql> show databases;
-
+--------------------+
-
| Database |
-
+--------------------+
-
| information_schema |
-
| mysql |
-
| performance_schema |
-
| test |
-
+--------------------+
-
4 rows in set (0.00 sec)
-
-
mysql>
-
搞定!!