深圳罗湖高端网站建设,下一页p30,淮南网络推广报价,程序员wordpress插件解决方法#xff1a;1、在my.cnf中#xff0c;增加“[mysqld]”和“skip-grant-tables”2行代码#xff0c;用于登录时跳过密码验证#xff1b;2、启动mysql服务#xff0c;并登录mysql#xff1b;3、连接mysql数据库#xff0c;使用UPDATE命令修改用户密码即可。linux上…解决方法1、在my.cnf中增加“[mysqld]”和“skip-grant-tables”2行代码用于登录时跳过密码验证2、启动mysql服务并登录mysql3、连接mysql数据库使用UPDATE命令修改用户密码即可。linux上mysql改密码忘了的解决方法修改密码1. 检查mysql服务是否启动如果启动关闭mysql服务//查看mysql服务状态[rootmytestlnx02 ~]# ps -ef | grep -i mysqlroot 22972 1 0 14:18 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir/var/lib/mysql --socket/var/lib/mysql/mysql.sock --pid-file/var/run/mysqld/mysqld.pid --basedir/usr --usermysqlmysql 23166 22972 0 14:18 pts/0 00:00:00 /usr/sbin/mysqld --basedir/usr --datadir/var/lib/mysql --plugin-dir/usr/lib/mysql/plugin --usermysql --log-error/var/log/mysqld.log --pid-file/var/run/mysqld/mysqld.pid --socket/var/lib/mysql/mysql.sockroot 23237 21825 0 14:22 pts/0 00:00:00 grep -i mysql//关闭服务[rootmytestlnx02 ~]# service mysql stop[rootmytestlnx02 ~]#2. 修改mysql的配置文件my.cnfmy.cnf配置文件的位置一般在/etc/my.cnf有些版本在/etc/mysql/my.cnf在配置文件中增加2行代码[mysqld]skip-grant-tables作用是登录mysql的时候跳过密码验证然后启动mysql服务并进入mysql[rootmytestlnx02 ~]# service mysqld start[rootmytestlnx02 ~]#[rootmytestlnx02 ~]# mysql -u rootType help; or \h for help. Type \c to clear the current input statement.mysql3. 修改密码连接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 changedmysql update mysql.user set authentication_stringpassword(root_password) where userroot;Query OK, 1 row affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 1mysql flush privileges;Query OK, 0 rows affected (0.00 sec)mysql exit4. 重启mysql服务先将之前加在配置文件里面的2句代码注释或删除掉然后重启mysql服务就可以使用刚刚设置的密码登录了。[rootmytestlnx02 ~]# service mysql start[rootmytestlnx02 ~]#[rootmytestlnx02 ~]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.p.s.在CentOS上的操作方式有所不同。执行修改密码的命令一直报错mysql update user set authentication_stringpassword(xxxxxxxx) where Userroot;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_password) where Userroot at line 1不可能是语法问题检查了很多遍最后发现CentOS下应该这样操作查看初始密码[rootVM_0_8_centos ~]# grep temporary password /var/log/mysqld.log2018-09-26T04:25:54.927944Z 5 [Note] [MY-010454] [Server] A temporary password is generated for rootlocalhost: DN34N/?aIfZ可以看到初始密码为DN34N/?aIfZ使用初始密码登录[rootVM_0_8_centos ~]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.12 MySQL Community Server - GPLCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.修改密码mysql ALTER USER root IDENTIFIED BY xxxxxxxxx;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql ALTER USER rootlocalhost IDENTIFIED BY xxxxxxxx;Query OK, 0 rows affected (0.11 sec)mysql flush privileges;Query OK, 0 rows affected (0.01 sec)mysql exitBye重启服务就生效了[rootVM_0_8_centos ~]# service mysqld stopRedirecting to /bin/systemctl stop mysqld.service[rootVM_0_8_centos ~]# service mysqld startRedirecting to /bin/systemctl start mysqld.service