Kioko Kiaza
Kioko Kiaza

Reputation: 1398

Missing databases

When I start my mysql server with usr/sbin/mysqld --skip-grant-tables --user=mysql & (debian 7) and I logged to mysql a show databases query result is this:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| UDA                |
| guikuzi            |
| hotel_guregas      |
| merkaklub          |
| mysql              |
| performance_schema |
| phpmyadmin         |
| superlinea         |
| test               |
+--------------------+
10 rows in set (0.00 sec)

and this is a info:

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)

After that if I stopped this mysql server and start via /etc/init.d/mysql start I have this:

# /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                       |
+---------------------------+----------------------------+

What´s is happening? I started the safe mode because I have to reset root password, but it´s not working either. Now I have my server in safe mode and it is working but I think that is not the best way

Any help or clue?

Thanks in advance

Upvotes: 0

Views: 2352

Answers (1)

miklosq
miklosq

Reputation: 95

Based on your post, It's quite obvious that in the first instance you started MySQL server without its privilege system turned on (--skip-grant-tables). This option turns off MySQL's internal privilege system, which gives anyone unrestricted access to all databases. So when you connected to the database server through your client, you bypassed any privilege checks and you could see all databases.

--skip-grant-tables This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases. "

See related MySQL docs for more info.

In the second instance, you started MySQL normally, the privilege system was turned on which means that connecting users may perform operations that are permitted to them based on their identity.

The MySQL privilege system ensures that all users may perform only the operations permitted to them. As a user, when you connect to a MySQL server, your identity is determined by the host from which you connect and the user name you specify. When you issue requests after connecting, the system grants privileges according to your identity and what you want to do.

See more info in the related MySQL docs.

Also, have a look at the answer to this post how to see which user is authenticated to your current MySQL session.

More simple, just type a "\s" and to see basic status information in the MySQL client prompt. For e.g.:

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
(...)

I hope the above helps. I tried to show you a basic pointer how to go about troubleshooting such a situation!

Upvotes: 2

Related Questions