Users and Rights


  • log onto the system from a command-line interface ( Terminal )
  • move the mysql or /mysql/bin folder or directory, depending upon the operating system

     ex.: 

        cd /usr/local/mysql/bin ( Unix or Linux )

            or

        cd c:\mysql\bin ( Windows )


  • log in to MySQL

     ex.: 

       mysql -u username -p


The -h hostname argument described bofore is optional, and I tend to leave it off unless I cannot get into MySQL otherwise.  If you set the root user password then it's time to use it now.

 

  • select which database you want to use

    ex.: 

       USE Test


  • quit out of MySQL

     ex.: 

        exit


Users and Privileges


Finally, there is the option of limiting users to particular hostnames.  The hostname is either the name of the computer on which the MySQL server is running (localhost being the most common value here) or the name of the computer from which the user will be accessing the server.  This can even be an IP address, should you choose.   To specify a particular host, change your statement to the following;


ex.: 

  Grant all on database.* To username@hostname Identified by 'password'


To allow for any host, use the hostname wildcard character (%).

ex.: 

  Grant All on database.* To username@'%' Identified by 'password'


To Create New Users


  • log onto the system from a command-line interface ( Terminal )
  • move the mysql or /mysql/bin folder or directory, depending upon the operating system
  • log into the mysql monitor as root user

     ex.: 

        mysql -u root -p


  • create a new databases

     ex.: 

         create database alpacas;

         create database movies;


  • create a user that has administrative level privileges on the alpacas database

     ex.: 

        Grant select, insert, delete, update, create, drop, alter, index on alpacas.* To llama@localhost IDENTIFIED By 'camel';


  • create a user that has browsing-level access to both databases

     ex.: 

            Grant select on alpacas.* To webuser@'%' IDENTIFIED BY 'browsing';

            Grant select on movies.* To webuser@'%' IDENTIFIED BY 'browsing';


  • exit out of MySQL

     ex.: 

        quit


  • Apply the changes using mysqladmin

     ex.: 

         bin/mysqladmin -u root -p reload