您的位置:首页 > 运维架构 > Linux

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

2016-06-16 12:59 441 查看

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

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

【mysqld】下

skip-grant-tables


my.cnf 一般是在 etc目录下

然后就是修改密码

在 终端 输入 mysql -u root -p

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


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

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

use mysql;

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


最后修改密码并退出

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 1
mysql> update user set password=PASSWORD("root") where user='root';
Query OK, 3 rows affected (0.07 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> exit
Bye


重启mysql使修改生效

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


这样基本问题就解决了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 密码 linux 终端