I'm using MySQL server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0 on a Raspberry Pi.
This is my /etc/mysql/my.cnf
:
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
#bind-address = 0.0.0.0
I've tried this:
sudo mysql_secure_installation
Change root password: y
Password
Retyped password
Remove anonymous users: y
Disallow root login remotely: n
Remove test database: y
Reload priviledges: y
CREATE USER 'root'@'%.%.%.%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%.%.%.%' WITH GRANT OPTION;
FLUSH PRIVILEDGES;
service mysql restart
In my.cnf
, with bind-address commented, I can access from localhost
, but not from remote host using SQL Workbench.
With bind-address uncommented, I cannot access from localhost
, but I can access from remote host using SQL Workbench, e.g.:
mysql -u root
mysql: unknown variable 'bind-address=0.0.0.0'
This is my users table:
MariaDB [(none)]> select user, host, password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *054D119DEAD56E226D8356557796BFA72E71BA40 |
| root | %.%.%.% | *054D119DEAD56E226D8356557796BFA72E71BA40 |
| root | % | *054D119DEAD56E226D8356557796BFA72E71BA40 |
+------+-----------+-------------------------------------------+
How do I configure the server to allow local and remote access for root from any IP?
Open a terminal or SSH connection and type sudo iptables -A INPUT -p tcp -s X.X.X.X –dport YYYY -j ACCEPT. Replace X.X.X.X with the IP address for the device you wish to allow MySQL connections from, and replace YYYY with the matching port value from your MySQL configuration file (eg. 3306).
Go to PhpMyAdmin and then: localhost/phpmyadmin -> User accounts -> Edit privileges -> Login Information. Change Host name drop down to Any host or type any IP 192.168. 0.3 or even with masking 192.168. 0.
Add a line over bind-address = 0.0.0.0 with [mysqld] like:
[mysqld]
bind-address = 0.0.0.0
In your case both, the server and the local client, reads the bind address and the client want to connect to the IP 0.0.0.0
According to this link it seems that the mysql client doesn’t recognize the bind address.
In order to connect locally I have to use this line:
mysql --no-defaults -u[username] -p[password] [database]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With