How to allow the user “sonia” to connect to the server from localhost using the password “passwd”. Login as root.

How to allow the user “sonia” to connect to the server from localhost using the password “passwd”. Login as root.

Switch to the MySQL db. Give privs. Update privs

# mysql -u root -p

mysql> use mysql;

mysql> grant usage on *.* to sonia@localhost identified by ‘passwd’;

mysql> flush privileges;

To allow the user “sonia” to connect to the MySQL server from localhost using the password “passwd” and grant necessary privileges, you can follow these steps:

  1. Log in to MySQL as the root user:
    bash
    mysql -u root -p

    You will be prompted to enter the root password.

  2. Switch to the MySQL database:
    sql
    USE mysql;
  3. Create a user for “sonia” if not already exists and grant necessary privileges:
    sql
    CREATE USER 'sonia'@'localhost' IDENTIFIED BY 'passwd';
    GRANT ALL PRIVILEGES ON *.* TO 'sonia'@'localhost' WITH GRANT OPTION;

    This will create the user “sonia” with the password “passwd” and grant all privileges on all databases and tables. Adjust privileges according to your requirements.

  4. Update privileges to apply the changes:
    sql
    FLUSH PRIVILEGES;

Now, “sonia” should be able to connect to the MySQL server from localhost using the specified password and have the necessary privileges.