Linux Centos-6 Mysql修改密码 不需要输入原密码

来源:互联网 发布:windows一直在检查更新 编辑:程序博客网 时间:2024/06/06 11:04

Linux Centos-6 Mysql修改密码 不需要输入原密码

首先需要配置 my.cnf 文件 在其中 加入一行

【mysqld】下

skip-grant-tables

my.cnf 一般是在 etc目录下


然后就是修改密码

在 终端 输入 mysql -u root -p

[root@guhaotechnology ~]# mysql -u root -pEnter password: 

会出现让你键入密码 由于我们修改过配置文件此处不用任何输入直接回车即可

接下来是 进入mysql 还需要选择下

use mysql;

mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed

最后修改密码并退出

mysql> update user set password("root") where user='root';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '("root") where user='root'' at line 1mysql> update user set password=PASSWORD("root") where user='root';Query OK, 3 rows affected (0.07 sec)Rows matched: 3  Changed: 3  Warnings: 0mysql> exitBye

重启mysql使修改生效

[root@guhaotechnology ~]# service mysqld restartStopping mysqld:                                           [  OK  ]Starting mysqld:                                           [  OK  ]

这样基本问题就解决了

0 0
原创粉丝点击