domingo, 18 de junio de 2023

create user with remote access

To create a MySQL user called "admin" with the password "asterisk" and grant all privileges to the "asterisk" database, as well as allow remote MySQL connections, follow these steps:

  1. Log in to the MySQL server as the root user:

    css
    mysql -u root -p
  2. Enter the MySQL root password when prompted.

  3. Create a new user "admin" with the password "asterisk":

    sql
    CREATE USER 'admin'@'%' IDENTIFIED BY 'asterisk';

    This creates a user named "admin" that can connect from any remote host ("%").

  4. Grant all privileges to the user on the "asterisk" database:

    sql
    GRANT ALL PRIVILEGES ON asterisk.* TO 'admin'@'%';
  5. Flush the privileges to apply the changes:

    sql
    FLUSH PRIVILEGES;

Allow remote connection

nano my.cnf.d/mariadb-server.cnf



[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mariadb/mariadb.log

pid-file=/run/mariadb/mariadb.pid

bind-address=0.0.0.0


Restart the service

 systemctl restart mysqld


TEST

 mysql -h 145.27.107.195 -u admin -pasterisk