Stupid question maybe but for some reasons, i am unable to see my RDS mysql db instance after connecting via mysql from my ec2 instance. The EC2 and the RDS security groups have the 3306 port open between them, no issues. The database is already created as i can see it on the RDS console.
mysql -h RDS endpoint -P 3306 -u root -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| innodb |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
Regards,
Ochen
Related
I have create a mysql database locally in the unix macos Mojave environment, when entering mysql and entering command
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| cms_blog |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
then when entering sequelpro I attempt to connect to 'cms_blog'
Host: 127.0.0.1
default root and password for mysql
This is the error I am seeing
I'm wondering if because the database has no tables I am seeing this error, or because sequelpro may be looking to a mamp mysql conf file rather than the homebrew mysql I am using via cli. Any information would be greatly appreciated.
I'm trying to use grafana with mysql. MySql is getting data from wordpres. I can connect to the MySql database with grafana but any attempt to query the database results in a permission error quoted below. Does anyone know what I'm doing wrong? I made sure to FLUSH PRIVILEGES; when creating this account.
What account is being used?
mysql> SELECT USER(),CURRENT_USER();
+-------------------+-------------------+
| USER() | CURRENT_USER() |
+-------------------+-------------------+
| grafana#localhost | grafana#localhost |
+-------------------+-------------------+
1 row in set (0.00 sec)
What permissions does the account have?
mysql> show grants for 'grafana'#'localhost';
+------------------------------------------------------------------------+
| Grants for grafana#localhost |
+------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'grafana'#'localhost' WITH GRANT OPTION |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)
Can I select from a table? (Yes)
mysql> select * from wp_users;
+----+---------------+------------------------------------+---------------+---------------------------+----------+---------------------+-----------------------------------------------+-------------+---------------+
| ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name |
+----+---------------+------------------------------------+---------------+---------------------------+----------+---------------------+-----------------------------------------------+-------------+---------------+
| 1 | admin | ********************************** | admin | a.guy#place.com | | 2019-02-22 18:09:58 | | 0 | something |
+----+---------------+------------------------------------+---------------+---------------------------+----------+---------------------+-----------------------------------------------+-------------+---------------+
1 row in set (0.00 sec)
What is my mysql info?
mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper
Connection id: 42787
Current database: information_schema
Current user: root#localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.25-0ubuntu0.18.04.2 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 43 days 2 hours 29 min 53 sec
Threads: 3 Questions: 3576291 Slow queries: 0 Opens: 1570 Flush tables: 1 Open tables: 692 Queries per second avg: 0.960
--------------
What query am a trying to run in grafana?
SELECT
user_registered,
user_login
FROM wp_users
I tried with with and without a trailing ; - no change.
What does grafana give back to me with this query?
Error 1142: SELECT command denied to user 'grafana'#'localhost' for table 'wp_users'
I realize that this account has too many permissions, but seeing as grafana thinks it doesn't have enough, for now I'm trying to get it to work with at least more than it needs.
After being stumped by this for a few hours, the notion of looking at logs was suggested to me. Since MySql doesn't have logs enabled by default, I changed the settings to enable the logs and restarted MySql. After doing this everything worked fine. It seems all I had to do was to restart the service.
The solution:
sudo service mysql restart
I ran MariaDB as Docker - expose port 3306 to localhost:3307
Connect Database via localhost:3307
$ mysql -u tvgift -P 3307 -h localhost -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
Connect Database via 172.18.0.2:3306 (IP I got from $ docker inspect <docker ID>
$ mysql -u tvgift -P 3306 -h 172.18.0.2 -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| tvgift |
+--------------------+
2 rows in set (0.00 sec)
I tried another client (Using mycli) with both IP, result is same.
$ mycli mysql://tvgift:tvgift#localhost:3307/tvgift
mariadb tvgift#localhost:tvgift> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| tvgift |
+--------------------+
2 rows in set
Time: 0.013s
$ mycli mysql://tvgift:tvgift#172.18.0.2:3306/tvgift
mariadb tvgift#172.18.0.2:tvgift> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| tvgift |
+--------------------+
2 rows in set
Time: 0.013s
So, only mysql client have differ between two IP of one container service, can you tell me why?
localhost != any IP address. That is,
GRANT ... TO tvgift#'%' ...
does not include
GRANT ... TO tvgift#'localhost' ...
If you want to connect both via localhost and via an IP address or hostname, you must provide two GRANTs with the same permissions (such as ON tvgift.*).
I've read a lot of answers for this question, but didn't found the resolve.
I have an mysql server on Azure (ex. 13.25.147.140).
my.cnf:
[mysqld]
# bind-address=127.0.0.1
init_connect= ^`^xSET collation_connection = utf8_unicode_ci ^`^y
character-set-server = utf8
collation-server = utf8_unicode_ci
[client]
default-character-set = utf8
Then, I did sudo service mysql restart
Then, granted permission for root:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'57.26.24.157' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> SELECT user, host from user;
+------------------+--------------+
| user | host |
+------------------+--------------+
| root | % |
| root | 57.26.24.157 |
| debian-sys-maint | localhost |
| mysql.sys | localhost |
| paymon | localhost |
| phpmyadmin | localhost |
| root | localhost |
+------------------+--------------+
But when I tried to connect from my PC, I got this:
mysql -u root -p -h 13.25.147.140
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'57.26.24.157' (using password: YES)
How can I fix that?
By default, mysql disallow root login remotely, it is a security precaution.
If you want to use root to login remotely for some test, we can use this command to modify it:
[root#jasonvm etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host, user from user where user="root";
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
mysql> grant all privileges on *.* to 'root'#'%' identified by 'password' with grant option;
Query OK, 0 rows affected (0.00 sec)
Another VM to use root to login mysql:
[root#localhost ~]# mysql -u root -p -h 40.71.33.231
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
I have the following DBs visible in phpmyadmin:
but when I type the command show databases; it doesn't show all of them:
sudo mysql -u root
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
+--------------------+
4 rows in set (0.00 sec)
Why is this happening?
When you type SHOW DATABASES it only shows you the databases the current user has access to.