Mysql: Allow User all Privs
From: https://linuxconfig.org/mysql-allow-root-remote-access
MySQL: Allow root remote access
12 February 2022 by Korbin Brown
The purpose of this tutorial is to show how to access MySQL remotely with
the root account. Conventional security practice is to disable remote access
for the root account, but it is very simple to turn on that access in a
Linux system.
Read on and follow through the step by step instructions to allow root
remote access in your MySQL server.
In this tutorial you will learn:
- How to allow remote access to the root accout in MySQL
Entering no on the disallow remote root login prompt
Software Requirements and Linux Command Line Conventions
Category | Requirements, Conventions or Software Version Used
|
System | Linux system
|
Software | MySQL
|
Other | Privileged access to your Linux system as root or via the sudo
command.
|
Conventions | # – requires given linux commands to be executed with root
privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non
-privileged user
|
MySQL: Allow root remote access step by step instructions
NOTE
Even after configuring MySQL to allow remote connections to the root
account, you still need to allow connections to MySQL through the Linux
firewall and make sure that MySQL is bound to an accessible interface. If
you have not already configured those aspects, first see our guide on MySQL:
Allow remote connections and then come back.
Step 1
To allow remote connections to the root account in MySQL, you should
execute the mysql_secure_installation command. Normally you run this command
when first setting up MySQL, but it can be run again at any point if you
need to reset the root account password or allow remote connections to the
account.
$ sudo mysql_secure_installation
Step 2
Follow the prompts until you reach one that asks Disallow root login remotely?
and on this prompt, simply enter no.
Step 3
Once you finish going through the rest of the prompts, you will be able
to access your MySQL server from remote systems using the root account. Of
course, this is assuming that your firewall is correctly configured and your
MySQL server (port 3306 by default) is already accessible over the
internet.
step 4
If this does not work for you, you can try editing the mysql.user entry
for root directly.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
mysql> UPDATE mysql.user SET host='%' WHERE user='root';
And then restart MySQL:
$ sudo systemctl restart mysql
Closing Thoughts
In this tutorial, we saw how to allow remote access to the root account in
MySQL. This is a simple setting to configure inside of the
mysql_secure_installation prompts, which everyone is recommended to run
through upon initial installation of MySQL server on Linux.
Related Linux Tutorials:
- Things to install on Ubuntu 20.04
- Things to do after installing Ubuntu 20.04 Focal Fossa Linux
- Linux Configuration files: Top 30 most important
- Things to do after installing Ubuntu 22.04 Jammy Jellyfish…
- Can Linux Get Viruses? Exploring the Vulnerability of Linux…
- An Introduction to Linux Automation, Tools and Techniques
- Ubuntu 20.04 Tricks and Things you Might not Know
- How to mount ISO image on Linux
- Things to install on Ubuntu 22.04
- Linux Download