关于设置“权限”在MySql中

发布于 2024-10-01 16:47:14 字数 1247 浏览 1 评论 0原文

我使用 PhpMyAdmin 来设置 mysql 表等。

我还拥有对所有内容的根(完全)访问权限。

目前我在 phpMyAdmin 的权限选项卡下有这个:

  USER:       HOST:       PASS:      GLOB PRIVILEGES:
phpmyadmin  localhost   Y    USAGE          No  
root    127.0.0.1   Y    ALL PRIVILEGES       Y 
root    localhost   Y    ALL PRIVILEGES       Y 
root    domain.com  Y    ALL PRIVILEGES       Y 
db1     localhost   Y    ALL PRIVILEGES       Y 
db2     localhost   Y    ALL PRIVILEGES       Y 
user    localhost   Y    USAGE                No    

我用它通过 PHP 连接:

$dbhost ='localhost';
$dbuser ='db2';
$dbpass ='password_here';
$dbname ='db2';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn) or die(mysql_error());
mysql_set_charset('utf-8', $conn);

让我困惑的是,如果我更改用户的密码,让我们说“db2”,然后尝试在我的 PHP 代码中使用它进行连接,我无法访问。我使用旧密码,即使我在 phpMyAdmin 中更改密码到数据库,它仍然有效。 我什至不记得设置第一个密码,那肯定是很久以前的事了。 这是我的第一个问题! 顺便说一句,当我单击“更改权限”时,显示是否应该使用密码的字段将在下拉列表中显示“不要更改密码”。它不应该说“使用文本字段”之类的东西吗?

其次,我需要知道它应该如何设置,从开始到结束......

我有自己的服务器,我是维护自己的服务器的菜鸟,但我每天都在学习。

但这个信息我在网上没有找到。

我需要在我的服务器上设置什么?我的.cnf? ETC...

I use PhpMyAdmin to setup mysql tables and such.

I also have root (full) access to everything.

Currently I have this in my phpMyAdmin under the privileges tab:

  USER:       HOST:       PASS:      GLOB PRIVILEGES:
phpmyadmin  localhost   Y    USAGE          No  
root    127.0.0.1   Y    ALL PRIVILEGES       Y 
root    localhost   Y    ALL PRIVILEGES       Y 
root    domain.com  Y    ALL PRIVILEGES       Y 
db1     localhost   Y    ALL PRIVILEGES       Y 
db2     localhost   Y    ALL PRIVILEGES       Y 
user    localhost   Y    USAGE                No    

And I use this to connect via PHP:

$dbhost ='localhost';
$dbuser ='db2';
$dbpass ='password_here';
$dbname ='db2';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn) or die(mysql_error());
mysql_set_charset('utf-8', $conn);

What confuses me is that if I change the password of the user lets say "db2" to something, and try using that in my PHP code for connecting, I don't get access. I am using an old password and it works even though I change passwords in phpMyAdmin to the database.
I don't even remember setting the first password up, it must have been a long time ago.
Thats my first problem!
Btw, when I click "change privileges", then the fields where it says if it is supposed to use password or not, is displaying "Dont change the password" from the drop list. Shouldn't it say something like "Use textfield"?

Second is that I need to know how it SHOULD be set up, from the start to end...

I have my own server and I am a rookie at maintaining my own servers, but I am learning everyday.

But this information is something I didn't find on the web.

What do I need to setup on my server? my.cnf? etc...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对不⑦ 2024-10-08 16:47:16

尝试

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='db2';
FLUSH PRIVILEGES;

try

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='db2';
FLUSH PRIVILEGES;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文