mirror of
https://pagure.io/fedora-docs/quick-docs.git
synced 2024-12-01 07:39:48 +00:00
80 lines
2 KiB
Text
80 lines
2 KiB
Text
|
= How To Allow Remote Access MYSQL/MariaDB/MYSQL Community
|
|||
|
|
|||
|
== Add New Rule to Firewalld
|
|||
|
|
|||
|
Open SQL port (3306) on FireWalld:
|
|||
|
|
|||
|
----
|
|||
|
sudo firewall-cmd --permanent --zone=public --add-service=mysql
|
|||
|
----
|
|||
|
|
|||
|
## OR ##
|
|||
|
|
|||
|
----
|
|||
|
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp
|
|||
|
----
|
|||
|
|
|||
|
== Restart firewalld.service
|
|||
|
|
|||
|
----
|
|||
|
systemctl restart firewalld.service
|
|||
|
----
|
|||
|
|
|||
|
== Editing Conf. Files:
|
|||
|
|
|||
|
Configuration files:
|
|||
|
|
|||
|
* MySql -> `/etc/my.cnf/`
|
|||
|
* MySql Community -> `/etc/my.cnf.d/community-mysql-server.cnf`
|
|||
|
* MariaDB -> `/etc/my.conf`
|
|||
|
|
|||
|
NOTE: you can ensure that with the following command `rpm -qc [package]`.
|
|||
|
|
|||
|
Navigate to the line that begins with the bind-address directive. It will look like this:
|
|||
|
you could set this directive to a wildcard IP address, either *, ::, or 0.0.0.0:
|
|||
|
|
|||
|
----
|
|||
|
bind-address = 0.0.0.0
|
|||
|
----
|
|||
|
|
|||
|
After changing this line, save and close the file and then restart the MySQL service:
|
|||
|
|
|||
|
----
|
|||
|
sudo systemctl restart {mysqld|mariadb}
|
|||
|
----
|
|||
|
|
|||
|
== Creating a USER
|
|||
|
|
|||
|
----
|
|||
|
CREATE USER 'your_username'@'host_ip_addr' IDENTIFIED BY 'your_password';
|
|||
|
----
|
|||
|
|
|||
|
NOTE: Replace your_username and your_password depending on what you want the username and password to be. Here, host_ip_addr is the hostname or IP address of the computer from where you want to connect to the MySQL/MariaDB server. You can also use % as host_ip_addr if you want to connect from any computer. It can also be something like 192.168.2.% if you want to connect from computers from the IP range 192.168.2.1 – 192.168.2.254.
|
|||
|
|
|||
|
== Allow Access
|
|||
|
|
|||
|
----
|
|||
|
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'%';
|
|||
|
IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;
|
|||
|
----
|
|||
|
|
|||
|
#OR
|
|||
|
|
|||
|
It is common for people to want to create a "root" user that can connect from anywhere, so as an example, we'll do just that, but to improve on it we'll create
|
|||
|
a root user that can connect from anywhere on the local area network (LAN)
|
|||
|
|
|||
|
----
|
|||
|
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.100.%'
|
|||
|
IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;
|
|||
|
----
|
|||
|
|
|||
|
----
|
|||
|
FLUSH PRIVILEGES;
|
|||
|
----
|
|||
|
|
|||
|
== Connecting
|
|||
|
|
|||
|
----
|
|||
|
mysql -u [USER] -h [IP] -p
|
|||
|
----
|