How to create MySQL database on CentOS/RHEL/Oracle server step by step guide for beginner


Create Database In Mysql | In this tutorial we learn how to create MySQL database on linux server using mysql promt and php script also.

Create MySQL database using mysql promt

To create  database in mysql  we require special privileged.To create mysql database we are using root user and login the mysql server and execute the below command to create mysql database through mysql promt.

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database techrideradmin;
Query OK, 1 row affected (0.00 sec)

Now database has been created after executing the above command.

After creating database we can list the databases using below command through mysql pomt.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| techrideradmin     |
+--------------------+
3 rows in set (0.00 sec)
How to create MySQL database on CentOS/RHEL/Oracle server step by step guide for beginner,Create Database In Mysql
How to create MySQL database on CentOS/RHEL/Oracle server step by step guide for beginner 

Create mysql  database using php script

We can create database in mysql  using php script we use mysql_query function and two parameters need to be pass one is connection parameter which detect the conncetion is established or not and other is sql query.

Lets take an example to create mysql database using php script.

<html>
   <head>
      <title>Create MySQL database on linux system</title>
   </head>
   <body>
      <?php
         $mysql_host = 'localhost';
         $mysql_user = 'root';
         $mysql_pass = 'passwordofroot';
         $conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
        
         if(! $conn ) {
            die('Could not connect the server: ' . mysql_error());
         }
         echo 'Connection successfully established';
         $sql = 'CREATE DATABASE techrideradmin';
         $result = mysql_query( $sql, $conn );
        
         if(! $result ) {
            die('Database creation failed: ' . mysql_error());
         }
         echo "Database techrideradmin created successfully\n";
         mysql_close($conn);
      ?>
   </body>
</html>

That’s all.If this article is helpful please share it!!!!

SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

2 comments:

  1. Awesome,Thank you so much for sharing such an awesome blog
    Really the post is very unique.every concepts are captured nice.
    Thank you for sharing any good knowledge and thanks for fantastic efforts.

    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    hadoop training in chennai

    hadoop training in bangalore



    ReplyDelete
  2. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    Igained more knowledge from your blog. Keep Doing..

    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    hadoop training in chennai

    hadoop training in bangalore



    ReplyDelete