当我使用usr / sbin / mysqld启动我的mysql服务器时--skip-grant-tables --user = mysql& (debian 7)我登录到mysql一个show databases查询结果是这样的:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| UDA |
| guikuzi |
| hotel_guregas |
| merkaklub |
| mysql |
| performance_schema |
| phpmyadmin |
| superlinea |
| test |
+--------------------+
10 rows in set (0.00 sec)
这是一个信息:
mysql> SHOW VARIABLES WHERE Variable_Name LIKE "%dir";
+---------------------------+----------------------------+
| Variable_name | Value |
+---------------------------+----------------------------+
| basedir | /usr |
| character_sets_dir | /usr/share/mysql/charsets/ |
| datadir | /var/lib/mysql/ |
| innodb_data_home_dir | |
| innodb_log_group_home_dir | ./ |
| lc_messages_dir | /usr/share/mysql/ |
| plugin_dir | /usr/lib/mysql/plugin/ |
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+---------------------------+----------------------------+
9 rows in set (0.00 sec)
之后如果我停止了这个mysql服务器并通过/etc/init.d/mysql start启动我就有了这个:
# /etc/init.d/mysql start 3 ↵
[ ok ] Starting mysql (via systemctl): mysql.service.
[root@debian:~]
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.5.35-0+wheezy1 (Debian)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.01 sec)
mysql> SHOW VARIABLES WHERE Variable_Name LIKE "%dir";
+---------------------------+----------------------------+
| Variable_name | Value |
+---------------------------+----------------------------+
| basedir | /usr |
| character_sets_dir | /usr/share/mysql/charsets/ |
| datadir | /var/lib/mysql/ |
| innodb_data_home_dir | |
| innodb_log_group_home_dir | ./ |
| lc_messages_dir | /usr/share/mysql/ |
| plugin_dir | /usr/lib/mysql/plugin/ |
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+---------------------------+----------------------------+
发生了什么事?我启动了安全模式,因为我必须重置root密码,但它也无法正常工作。现在我的服务器处于安全模式,它正在工作,但我认为这不是最好的方式
任何帮助或线索?
提前致谢
答案 0 :(得分:1)
根据您的帖子,很明显,在第一个实例中,您启动了 MySQL 服务器而未启用其权限系统(--skip-grant-tables)。此选项将关闭 MySQL 的内部权限系统,允许任何人无限制地访问所有数据库。因此,当您通过客户端连接到数据库服务器时,您绕过了任何权限检查,您可以看到所有数据库。
- skip-grant-tables此选项使服务器在不使用权限系统的情况下启动,这使任何人都可以访问 服务器不受限制地访问所有数据库。 “
有关详细信息,请参阅related MySQL docs。
在第二个实例中,您通常启动 MySQL ,启用了权限系统,这意味着连接用户可以根据其身份执行允许的操作。
MySQL权限系统确保所有用户只能执行 允许他们的操作。作为用户,当您连接到MySQL时 服务器,您的身份由您连接的主机确定 以及您指定的用户名。当您发出请求后 连接时,系统根据您的身份授予权限 以及你想做什么。
查看related MySQL docs中的更多信息。
另外,请查看this post的答案,了解如何查看当前 MySQL 会话的用户身份。
更简单,只需键入“\ s”并在 MySQL 客户端提示中查看基本状态信息。例如:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.35-0ubuntu0.13.10.2 (Ubuntu)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \s
--------------
mysql Ver 14.14 Distrib 5.5.35, for debian-linux-gnu (x86_64) using readline 6.2
Connection id: 37
Current database:
Current user: ubuntu@localhost
(...)
我希望以上有所帮助。我试图向您展示如何解决这种情况的基本指针!