Home  >  Article  >  Database  >  MySQL 用户登录密码和远程登录权限问题

MySQL 用户登录密码和远程登录权限问题

WBOY
WBOYOriginal
2016-06-07 17:33:49943browse

1.mysql数据库,忘记root用户登录密码。 解决如下: a.重置密码 #/etc/init.d/mysqld stop #mysqld_safe --user=mysql --skip-gr

1.mysql数据库,忘记root用户登录密码。

解决如下:

a.重置密码

#/etc/init.d/mysqld stop

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

#mysql -u root mysql

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

mysql> FLUSH PRIVILEGES;

mysql> quit;

b.使用新密码登录

#mysql -u root -pnewpassword

2.远程登录权限

mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

上面授权是允许myuser用户,从任何机器都能访问mysql服务器。

%代表任何客户端,,也可以是localhost,或者是某一ip地址。

CentOS 配置MySQL允许远程登录

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn