access mysql from remote 1

access mysql from remote

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     WITH GRANT OPTION;


#you need to change ufw for allowing 3306 port.

sudo ufw allow 3306

#if you are in aws ec2, you have to change the security group also

Here is what the above code is Doing:
1. Create a user named ‘monty’ with the password ‘some_pass’
2. Grant all privileges on all databases and tables of the MySQL server to the ‘monty’ user.
3. Create a user named ‘monty’ with the password ‘some_pass’ that can connect from any host.
4. Grant all privileges on all databases and tables of the MySQL server to the ‘monty’ user that can connect from any host.

Similar Posts