Online Learning Platform

DBMS > Structural Query Language (SQL) > How to create user in MySQL?

in your MYSQL DBMS there is a database called "MYSQL". Under this database there is views file called 'user' as follows:

 

This table contains user name and password. Also it shows respective prevalances. To create an user with name asad  following are the script:

CREATE USER asad@localhost IDENTIFIED BY '1234';

after creating the user it needs granting previlages:

GRANT select, INSERT on school.student TO asad@localhost;

This above command will allows permission to asad only on the table student in the database school. Moreover, he can only provide commands related to SELECT and  INSERT on student table.

To withdraw this right the following are the command:

REVOKE INSERT, SELECT  ON school.student FROM asad@localhost;

Note: If you practice on local machine and like Xampp software  then you have edit two file to enter in MySQL DBMS:

1. /xampp/password.txt

    - change user name and password: 

    MySQL (phpMyAdmin):

    User: root
    Password:

 

2. /xampp/phpmyadmin/config.inc.php

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';

Prev
Trigger example using MySQL database

No More

Feedback
ABOUT

Statlearner


Statlearner STUDY

Statlearner