Missing databases - mysql

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

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!

Related

Unable to set password of myphpadmin

The solutions those posts stated:
Adhere to the password policy.
uninstall plugin validate_password (which I don't want to do )
My password policy:
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
Now I don't know what will satisfy the MySQL password validation plugin, I tried a ton of passwords that had all the requirements stated below, like
Ml9506&#, Qwerty123!##, qwertyQWERTY098)(* and a ton of more passwords.
I got this error while installing PHPMyAdmin:
MySQL ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
I also tried changing the policy to LOW but that also didn't help.
Set policy level to low.
mysql> SET GLOBAL validate_password_policy=LOW;
OR
mysql> SET GLOBAL validate_password_policy=0;
check password validation policy level with:
$ SHOW VARIABLES LIKE 'validate_password%';
If the password policy doesn't change, exit from the MySQL prompt and restart the MySQL service from your Terminal window:
$ sudo systemctl restart mysql
then go to MySQL and create your user

PHPMyAdmin | Event Scheduler cannot enabled and get #1577 error

I've stuck on this problem for a while.
I need to schedule a job for my query daily so I have to set global event_scheduler = ON
and I got this message ..
1577 - Cannot proceed because system tables used by Event Scheduler were found damaged at server start
some guys told me i have to restart db and do it again but it's not work.
I was going to my.cnf and type event_scheduler = ON in [mysqld] section and restart again
and it's still DISABLED.
someone told me it's a bug of version 5.5 but i'm using 5.6 .....
MariaDB [(none)]> SHOW VARIABLES LIKE "%version%";
+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| innodb_version | 5.6.22-72.0 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 10.0.17-MariaDB |
| version_comment | Source distribution |
| version_compile_machine | i386 |
| version_compile_os | osx10.6 |
| version_malloc_library | system |
+-------------------------+---------------------+
so I have no any idea what should i do with this thing :(
I also can't access the EVENT table in information_schema db with the same error.
if anyone can solve my problem. i'll owe you guys my entire life.
** i sincerely apologise if it's a stupid question **
Ps. I use XAMPP.
It is generally a good idea to research error codes and messages:
https://serverfault.com/questions/385015/mysql-damaged-system-tables
https://serverfault.com/questions/562282/mysqldump-error-1557-corrupt-event-table
https://serverfault.com/questions/100685/cannot-proceed-because-system-tables-used-by-event-scheduler-were-found-damaged
https://bugs.mysql.com/bug.php?id=70975

accidentally deleted mysql database

I was working with netbean's database explorer (services tab) and accidentally deleted one of the databases.
I was trying to connect to a database and there were 2 options in the context menu for connecting.
1)Connect
2)Delete
I accidentally hit delete. It did not even ask me for confirmation. Is there anyway to recover the database?
I don't have access to mysql server. I can just connect to the database using mysql workbench.
Thanks a ton!
If you have the binary logging enabled, then you might have a chance to use it to restore your database.
Else use an older backup and restore it !
To find binary logs status :
mysql> show variables like '%bin%';
+---------------------------------+----------------------+
| Variable_name | Value |
+---------------------------------+----------------------+
| binlog_cache_size | 32768 |
| innodb_locks_unsafe_for_binlog | OFF |
| log_bin | OFF |
| log_bin_trust_function_creators | OFF |
| max_binlog_cache_size | 18446744073709547520 |
| max_binlog_size | 1073741824 |
| sync_binlog | 0 |
+---------------------------------+----------------------+
7 rows in set (0.00 sec)

MySQL: different evaluation command line and in mysql console

I was surprised mysql evaluates the same statement differently command line using mysql -e "$query" and in the mysql console when you run mysql and type queries.
I have a table with timestamp field create_date. I run the same command differently and get different results:
In mysql console:
$ mysql -uuser -ppassword database1
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33608
Server version: 5.5.32-31.0 Percona Server (GPL), Release rel31.0, Revision 549
Copyright (c) 2009-2013 Percona Ireland Ltd.
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> select DATE_ADD(create_time, INTERVAL DATEDIFF('2014-03-13', "2013-03-13") DAY) as date from table1;
+---------------------+
| date |
+---------------------+
| 2014-03-08 00:00:11 |
| 2014-03-08 00:00:22 |
| 2014-03-10 00:00:33 |
| 2014-03-10 00:00:44 |
| 2014-03-12 00:00:55 |
| 2014-03-12 00:00:32 |
| 2014-03-08 00:00:42 |
| 2014-03-08 00:00:23 |
+---------------------+
8 rows in set (0.00 sec)
The same query from command line using -e parameter gives null results:
$ mysql -uuser -ppassword urbanout_www -e 'select DATE_ADD(create_time, INTERVAL DATEDIFF('2014-03-13', "2013-03-13") DAY) as date from table1;'
+------+
| date |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
+------+
Any explanation of this?
When you use single quotes in the query, they're terminating the shell's quote, not being sent to MySQL. Try:
$ mysql -uuser -ppassword urbanout_www -e 'select DATE_ADD(create_time, INTERVAL DATEDIFF("2014-03-13", "2013-03-13") DAY) as date from table1;'

InnoDB Plugin Version command?

Is there any way to make MySQL tell you what version of the InnoDB plugin it's running? I know you can look at the documentation, but I'm trying to verify a potential bug if the plugin jives with the mysql version installed.
mysql> show variables like '%version%';
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| protocol_version | 10 |
| version | 5.1.50-community-log |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | unknown-linux-gnu |
+-------------------------+------------------------------+
I found the answer, so I'll pass this along.
1.You must be running the InnoDB plugin instead of the built-in mysql innodb. To do this, you must make these config changes to your my.cnf:
ignore_builtin_innodb
plugin-load = innodb=ha_innodb_plugin.so;innodb_trx=ha_innodb_plugin.so;innodb_locks=ha_innodb_plugin.so;innodb_lock_waits=ha_innodb_plugin.so;innodb_cmp=ha_innodb_plugin.so;innodb_cmp_reset=ha_innodb_plugin.so;innodb_cmpmem=ha_innodb_plugin.so;innodb_cmpmem_reset=ha_innodb_plugin.so
innodb_fast_shutdown = 0
Note: Load individual plugins, but make sure no spaces between the ";". Also innodb_fast_shutdown is optional, but recommended.
2.You must restart mysqld to take the new config changes.
3.Using your SQL interface, execute: "SELECT ##innodb_version;"
mysql> SELECT ##innodb_version;
+------------------+
| ##innodb_version |
+------------------+
| 1.0.11 |
+------------------+
1 row in set (0.00 sec)
Reference URLs:
Getting the version:
http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_version
Using the plugin engine
http://dev.mysql.com/doc/refman/5.1/en/replacing-builtin-innodb.html
When you have installed InnoDB Plugin you can check out the version by performing the following commands
SELECT * FROM information_schema.plugins;
SELECT ##innodb_version;