Managing the Database

Creating Users

To create users above and beyond the default privileged root user, issue the grant command. The grant command uses this syntax:
GRANT PRIVILEGES ON DATABASE.OBJECTS TO'USER'@'HOST' IDENTIFIED BY 'PASSWORD';

For example:
GRANT ALL PRIVILEGES ON *.* TO 'michele'@'localhost' IDENTIFIED BY 'secret';

This creates the user michele who can access anything locally. To change to the michele user, at the mysql command prompt, type:
exit

Then start MySQL from the command line with the new username and password. The syntax for specifying the username and password when starting MySQL is:
mysql -h hostname -u username -ppassword

If you don't want users to access tables other than their own, replace * with the name of the user's database, like this:
GRANT ALL PRIVILEGES ON `store`.* TO 'michele'@'localhost' IDENTIFIED BY 'secret';

You'll need to run the above line as root or as someone with permission. In the above code, the word store correlates to the database name to which privileges are assigned, which you'll create in the next section.

8.2.2. Creating a MySQL Database

You're going to create a database called store. The create database command works like this:
CREATE DATABASE `store`;

If this works, you'll get a result like this one:
Query OK, 1 row affected 0.03 sec
 
 
To start using this database, type:
USE `store`;
You will get the result:
Database changed.
Assuming you've done everything correctly, you'll be set up with new data and selected it for use. Creating tables is an important concept, so that's where we're headed!.


To rename a table, use ALTER TABLE table RENAME newtable. In this example, we are renaming the table from books to publications.
ALTER TABLE `books` RENAME `publications`;

 
Related Posts:
  • Top PHP Online Resources Top PHP Online Resources 5 Top excellent PHP online resource  http://www.php.net/ This is perhaps the most useful of the sites listed  in this appendix, simply because this is the site that contains up-to-date … Read More
  • All Operators Of PHP   All PHP Operators  An expression is the basic building block of the language. Anything with a value can be thought of as an expression. Examples include: 5 5+5 $a $a==5 sqrt(9) By combining many of these bas… Read More
  • 555 php Interview Questions What are “GET” and “POST”? What are the advantages of stored procedures, triggers, indexes? PHP? What is LAMP? How to Read an RSS Feed With PHP  What is the maximum length of a table name, database name, … Read More
  • PHP method of securely Tips PHP method of securely website PHP Web security tips Passwords used within your PHP application  should always be encrypted. If the server you are using does not support mcrypt(), use crypt() to encrypt the password… Read More
  • XML in PHP-SimpleXML-DOM-XMLReader There are many ways we can work with XML in PHP, and they’re all useful in different situations. There are three main approaches to choose from and they all have their advantages and disadvantages: 1. SimpleXMLis the most… Read More
  • How to Sending Data to a Database php How to Sending Data to a Database php Save Data to a Database by php The process of adding information to a table is similar  to creating the table itself in terms of which functions  you use, but the SQL quer… Read More
  • Free php classified script PHP Classified Script | The best classifieds software.Plug and Play. Our theme is plug and play and you dont need any extra plugins or other scripts to run your classified ads website. Also the installation process is .http:… Read More
  • php Sessions code Php Sessions Sessions are used to help maintain the values of variables across multiple web pages. This is done by creating a unique  session ID that is sent to the client browser. The browser  then sends the … Read More
  • Variables in PHP Variables in PHP Variables are used for storing a values, like text strings, numbers or arrays. When a variable is set it can be used over and over again in your script All variables in PHP start with a $ sign symbol. Th… Read More
  • Working with Cookies in PHP Cookies are key/value pairs, that are sent to the browser along with some other information, such as which paths the cookie is valid for and when it expires. Since PHP is designed to solve “the Web problem,” it has some g… Read More
  • PHP Array Introduction Function Description PHP  Testing Array and sizeof( )<?php$fixture = Array( );// $fixture is expected to be empty.$fixture[] = "element";// $fixture is expected to contain one element.?>A really simple way … Read More
  • PHP File Upload Script PHP File Uploading Code Take a moment to commit the following list to memory— it contains the variables that are automatically placed in the  $_FILES superglobal after a successful file upload.  The base of im… Read More
  • Creating a Php Script to Mail Your Form Php Mail Script According to the form action in simple_form.html, you  need a script called send_simpleform.php. The goal  of this script is to accept the text in  $_POST[sender_name], $_POST[sender_email],… Read More
  • PHPINFO-Displaying information about the PHP environment PHPINFO-Displaying information PHPINFO-about the PHP environment Functions that are built into PHP can be called from any PHP script. When you call functions, you are executing the code inside them, except the code &nbs… Read More
  • Top PHP Interview Questions with Answers For Job   What is PHP?     PHP is a server side scripting language  used for web development applications.     Php is the powerful tool for making dynamic website.     Many … Read More