Have you tried to Managing users in mysql 50

Asked By 10 points N/A Posted on -
qa-featured

Hello experts,

I am preparing a sever and database for my office.

Firstly I have to design for 50 users.

I am newbie and don’t know how to do this.

I have searched the term “managing users in MySQL 50” and found a variety of results.

I am looking for script with each explanation.

So I can make changes at any stage whenever I required.

SHARE
Best Answer by Joseph A Reese
Answered By 0 points N/A #166574

Have you tried to Managing users in mysql 50

qa-featured

Hi Toles,

First store all the 50  usernames and password s in csv file.

e.g mike,mike123

rose,rose123

zen,zen1234

Then write a  bash script to read the csv file  line by line and  then use the create user command to create mysql  users.

#!/bin/bash

INPUT=username.cvs

OLDIFS=$IFS

IFS=,

[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }

while read username pwd

do

cmd1="CREATE user’$username’@’localhost’  identified by password ‘$pwd’;"

cmd2="GRANT ALL PRIVILEGES ON *.* TO '$username'@'localhost' ;“

cmd3="FLUSH PRIVILEGES;"

SQL="${cmd1}${cmd2}${cmd3}"

$MYSQL -uroot -p -e "$SQL"

done

IFS=$OLDIFS

If you want to add or delete users you just need to update the csv file.

 

Hope this will help you. Best of luck

Best Answer
Best Answer
Answered By 0 points N/A #166576

Have you tried to Managing users in mysql 50

qa-featured

 

Hi,

Though you are new and you don’t know how to start to design and manage a database which contain 50 users. For these you have to follow these steps:

1.   First, you have to setup a database to your Server and which operation system you use. Which you will find helpful at this following link: https://dev.mysql.com/doc/refman/5.6/en/installing.html

2.   Then after finishing the setup, you have to create a database which includes a user table by using CREATE queries. Which you can follow in this link: https://dev.mysql.com/doc/refman/5.6/en/creating-database.html

Create Database syntex

3.   After that you have to create a table using these kind of syntax. https://dev.mysql.com/doc/refman/5.6/en/creating-tables.html

Create Table syntex

4.   Then you have to load your data in the table using INSERT syntax. You will find the necessary syntax in here: https://dev.mysql.com/doc/refman/5.6/en/loading-tables.html

The easy way to load a lot data by creating a text file which contain a row for each of your user name. You will find helpful if you visit at this site too: https://www.w3schools.com/sql/default.asp

And

https://dev.mysql.com/doc/refman/5.6/en/

Good Luck.

Related Questions