Online Shopping : Computers : Programming : Languages : PHP : access

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 4 people (50%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

How can i create database using PHP command. What rights i have to set on server.?

Mar 24th, 2009 20:30
chat alarab, vijay y, Rohit Savalia, chat


An abstract from
http://www.ksa-123.com
http://www.ksa-2000.com
http://www.chat-kuwait.com
http://www.vip-kuwait.com
http://www.chat-3rb.com
http://www.vip-3rb.com
http://www.3rb-chat.com
http://www.vipgulf.com
http://www.chat-gulf.com
http://www.vip-gulf.comis given below that 
answers the question.
<b>Connecting to the MySQL server: </b>
Before you work with MySQL, ensure that you have a user name and 
password with appropriate permissions for connecting to and accessing 
the MySQL database. 
The GRANT and REVOKE commands allow system administrators to create 
users and grant and revoke rights to MySQL users at four privilege 
levels:
Global level: The global privileges apply to all databases on a given 
server. These privileges are stored in the mysql.user table. REVOKE ALL 
ON *.* will revoke only global privileges.
Database level: Database privileges apply to all tables in a given 
database. These privileges are stored in the mysql.db and mysql.host 
tables. REVOKE ALL ON db.* will revoke only database privileges.
Table level: Table privileges apply to all columns in a given table. 
These privileges are stored in the mysql.tables_priv table. REVOKE ALL 
ON db.table will revoke only table privileges.
Column level: Column privileges apply to single columns in a given 
table. These privileges are stored in the mysql.columns_priv table. 
When using REVOKE you must specify the same columns that were granted.
Example:
mysql> GRANT ALL PRIVILEGES ON *.* TO name1@localhost  IDENTIFIED 
BY 'pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO name1@"%" IDENTIFIED BY 'pass' 
WITH GRANT OPTION;
The above commands will provide the user "name1" with superuser 
permissions. The user can connect from anywhere.
If you give a grant for a users that doesn't exists, that user is 
created. 
After getting the user_name, password you can connect to the database 
server.
To connect to the server invoke the mysql program from your shell 
prompt.
Syntax of the command is:
% mysql <options>
    % indicates the shell prompts
    mysql is the client program
    <options> include the following:
     -h host_name -u user_name -p password
     -u user_name -p (if host is localhost)
In our example, we have the following information :
    * host :localhost
    * user_name :subu
    * password :subu
    * database :sample_db
Given the above, to connect to the database server use the command:
[anand soft@localhost anandsoft]$ mysql -u subu -p
then enter your password subu at the password prompt.
<b>Connecting to Database Server Using PHP</b>
Two most commonly used functions to connect to the MySQL server are:.
   1. mysql_connect();
   2. mysql_select_db();
mysql_connect() function takes three arguments as localhost, username, 
password and mysql_select_db() takes database name as argument.
These two functions are called by the following statements:
mysql_connect(localhost,username,password) ;
mysql_select_db(databasename);
mysql_connect function connects to the server and mysql_select_db() 
selects the database under the username provided in mysql_connect() 
function.
If any wrong name is given, the server responds with an error.
You can connect to MySQL server through PHP by using the above given 
hostname, username, password by the way
mysql_connect('localhost','subu','subu');
mysql_select_db('sample_db');
This  function selects the database sample_db.
vijay,
http://www.ksa-123.com
http://www.ksa-2000.com
http://www.chat-kuwait.com
http://www.vip-kuwait.com
http://www.chat-3rb.com
http://www.vip-3rb.com
http://www.3rb-chat.com
http://www.vipgulf.com
http://www.chat-gulf.com
http://www.vip-gulf.com