• Skip to main content
  • Skip to primary sidebar

Founder at work

Master the skills to create and launch your next SaaS company

  • About Me
  • Reviews
  • Resources
  • Community
  • Contact
  • Lessons
  • Series
  • Search
  • Login

How to create a MySQL (SQL) database, username, password, and privileges from the CLI?

May 14, 2014 by Rick Hernandez Leave a Comment

Login in as an administrator to SQL CLI interface

mysql -u root -p

Now create a database where the user will belong to

CREATE DATABASE TheDatabase;

Now let’s go ahead and create a user

CREATE USER TheUser;

Next will be to give permission to the user for the selected database along with password, note this user will be able to drop tables, create table etc without no restrictions.

GRANT ALL ON TheDatabase.* TO 'TheUser'@'localhost' IDENTIFIED BY 'Th3passw0rd';

Don’t forget to flush the privileges or else your application might complain!

FLUSH PRIVILEGES;
Rick Hernandez

I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: MySQL, Programming, SQL

Primary Sidebar

Learn How To Take Your Idea And Convert It Into An App From Scratch Even If You Have Never Written A Single Line Of Code.

  • How to Find Your Next Great App Idea
  • The Secret To Getting PAID To Build Your Own App
  • How To Create Your App (SaaS, Mobile, VR, AR, Game)
  • How To Monetize Your Apps
Learn More
4.82 Ratings

Copyright © 2025 · JSecademy Blog Theme on Genesis Framework · WordPress · Log in