An Exploring South African

Things to do in Cape Town, the Helderberg, and the Cape Winelands

Menu

Skip to content
  • About
  • Explore

Ubuntu: How to Create a MySQL User Account via the Terminal CodeUnit 17 JAN 2011

To create a user account from a MySQL server instance, we need to make use of a CREATE USER call to the mysql.user table.

First, fire up MySQL in your terminal and login as an administrator account with:

mysql -u root -p

You will be prompted for your root password before being granted access to the MySQL monitor.

Now to grab a list of available user accounts on the system. Running:

select user,host from mysql.user;

If the user account that you wish to create doesn’t appear in that list, you are good to go. To create a new user account run the following query:

create user 'new-username'@'localhost' identified by 'password-for-new-account';

If you omit the @’localhost’ section, the user account will be generated with a host value of ‘%’. If you omit the identified by section, the user account will be created without a password (which is of course quite insecure).

Of course, this user isn’t linked to any databases yet, but this is simple to rectify with a:

grant all on mydatabase.* to useraccount@localhost

that will grant all rights for the user account to everything held in the mydatabase database. (Note that you generally don’t want to assign all rights, so will scale back as necessary in a real world example.)

Simple and nifty.

Related Link: http://dev.mysql.com/doc/refman/5.1/en/create-user.html

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

Related

Monday 17/01/2011CodeUnitadd user, create user, mysql, terminal, ubuntu, user accountCraig Lotter

About Craig Lotter

Software developer, husband and dad to two young ladies. Writer behind An Exploring South African. I don't have time for myself any more. View all posts by Craig Lotter →

Post navigation

← Photo Gallery: Jessica’s Growing Feet (2011-01-16) In the Arms of Grandpa Montgomery →

An Exploring South African

Curiosity, travel, and discovering new places. Craig Lotter's An Exploring South African is primarily a South African travel blog of things to do in and around Cape Town, the Helderberg, and the Cape Winelands.

Craig Lötter

A South African software developer at Touchwork, Craig Lotter is a husband to a cake baker, father to two young girls, and someone who is constantly looking for new places to explore. He is also not that bad of a writer either.

   

Instagram

Flowers in the sand. #dunevegetation #beachwalk #beach #gordonsbaybeach #gordonsbay #helderberg #southafrica #anexploringsouthafrican
No clouds in the sky means no spectacular Autumn sunset for me this evening. Oh well, at least the wind has finally died down! #sunset #beachwalk #beach #gordonsbaybeach #gordonsbay #helderberg #southafrica #anexploringsouthafrican
Golden light settling over Gordon's Bay main beach this evening. #goldenhour #beachwalk #beach #gordonsbaybeach #gordonsbay #helderberg #southafrica #anexploringsouthafrican
Moved about the sand dunes in the evening light this evening. #sanddunes #beachwalk #beach #gordonsbaybeach #gordonsbay #helderberg #southafrica #anexploringsouthafrican
Always disheartening to see. Following a very smelly week of Red Tide (toxic algae bloom) in our waters, the beach is absolutely littered with dead sea creatures at the moment. My walk along the Gordon's Bay main beach this evening yielded an unending line of dead crabs, sea urchins, sea anenemones, sea cucumbers, starfish, barnacles, abalone, skates, jellyfish, fish and even big octopuses. #redtide #algaebloom #octopus #beachwalk #beach #gordonsbaybeach #gordonsbay #helderberg #southafrica #anexploringsouthafrican
With no cakes having to go out the door for @thehelderbergcakecompany on Sunday, Chantelle, the girls, and I enjoyed a lazy afternoon of nibbling on pizza, sipping coffee, and rolling on the grass lawn at Bluebird Cafe, situated next to the old Mountain Breeze farm stall on the R44 between Stellenbosch and Somerset West. #pizza #sundaylunch #familytime #bluebirdcafe #mountainbreeze #r44 #stellenbosch #southafrica #anexploringsouthafrican

Subscribe via Email

Enter your email address to subscribe to this blog and receive notifications of new content via email.

Copyright © 2007-2021 Craig Lotter | Rugged Rock Studio | Proudly powered by WordPress