Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4603192
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:06:30+00:00 2026-05-22T00:06:30+00:00

For deploying an application, I’m required to create a database for basic user authentication.

  • 0

For deploying an application, I’m required to create a database for basic user authentication. To automate the process, I’ve written a MySQL batch file:

grant all on jetty.* to 'jetty'@'localhost' identified by 'jetty';

create database if not exists jetty;
use jetty;

create table if not exists users
(
  id int unsigned not null auto_increment,
  username varchar(100) not null,
  password binary(60) not null,
  primary key(id),
  unique(username)
);

create table if not exists roles
(
  id int unsigned not null auto_increment,
  role varchar(100) not null,
  primary key(id),
  unique(role)
);

create table if not exists user_roles
(
  user_id int unsigned not null,
  role_id int unsigned not null,
  unique(user_id, role_id),
  index(user_id)
);

insert into users(username, password) values('jetty', $2a$10$YX3cYqn9nHmCOmPZBHXrQ.2nxrktB3CRYG8tXmBmmWvrDKU8uwRSe');

I’ve been doing this for the first time, so I’m quite sure there are some things I might not get right. Is it actually a good idea to populate the users table with one user? To log into my application, there needs to be some account, still I’m not quite sure.

Another thing that bugs me is the grant statement. I wonder if grant all may not be restrictive enough.

Also, should I check for if not exists on every table I’m going to create?

Are there any best practices concerning batch scripts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:06:31+00:00Added an answer on May 22, 2026 at 12:06 am
    1. Bootstrapping your database with a user is OK. Just remember to update the script if ‘jetty’ ever leaves!
    2. GRANT ALL is not very restrictive, that is true. Locking down more tightly is usually a good thing.
    3. Checking IF NOT EXISTS means two things: (a) your script won’t fail if the table already exists [good] and (b) you won’t update an existing table [bad]. I like to DROP TABLE IF EXISTS and then CREATE TABLE.

    Be sure to make a backup before DROPing those tables though.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When deploying the application to the device, the program will quit after a few
I am deploying my Java application with Ant. Unfortunately my test deployment on the
I'm working on deploying a small community site. User registration requires nothing more than
My current project involves deploying an upgraded .exe file that runs as a Windows
Until now deploying my Application with macdeployqt worked fine, but after upgrading to Qt
I'm having problems deploying my application to a production server (shared hosting). Everything works
Tried deploying a simple web application (jboss 5.1, jboss seam 2.2.1) on a machine.
Has anyone got much experience deploying applications to Amazons EC2? I am considering doing
I'm fairly new to deploying desktop applications, so this is the first time I'm
I am thinking on deploying multiple (and different) web applications on the same server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.