2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > mysql root 不能登录_mysql root 用户不能登录的问题

mysql root 不能登录_mysql root 用户不能登录的问题

时间:2022-10-06 02:25:34

相关推荐

mysql root 不能登录_mysql root 用户不能登录的问题

#apt-get install mysql-server-5.0

#mysql -u root

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

发现不能登录。或者登录后没有权限操作。原因是因为在安装时没有给root设置密码而默认其为空的。

可以尝试以下的方法:

方法1 执行 root@hettvm2:~# mysqladmin -u root password 123456

设置了root的密码。

方法2

# /etc/init.d/mysql stop

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

# mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD('123456') where USER='root';

mysql> FLUSH PRIVILEGES;

mysql> quit

# /etc/init.d/mysql restart

# mysql -uroot -p

Enter password:

mysql>

方法3

MySQL安装之后,root的密码是空的。为了提高安全性有必要给root加上密码。

mysql –u root –p

password:

mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Password');

下次登陆时,就必须输入密码了。

给其他用户付权限则使用下面的语句:

grant all privileges on *.* to $usrname@"localhost" identified by "$password"

注:$是变量。表示用户名和密码

localhost是本地。如果是远程登录的话应该使用 “%”。

在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> select host,user,password from user;

+-----------+------------------+-------------------------------------------+

| host | user | password |

+-----------+------------------+-------------------------------------------+

| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| hettvm2 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| 127.0.0.1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| localhost | | |

| hettvm2 | | |

| localhost | debian-sys-maint | *6E20E21227143F48BD9E44BC7352C8855AE14A52 |

| % | starent | *BE6D39BA79EE21926B287198D86AC1573DA755EC |

| % | hettvm2 | *BE6D39BA79EE21926B287198D86AC1573DA755EC |

| localhost | hettvm2 | *BE6D39BA79EE21926B287198D86AC1573DA755EC |

+-----------+------------------+-------------------------------------------+

9 rows in set (0.00 sec)

mysql>

可以通过这个表查询用户。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。