php script to create mySQL database programmatically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mistral

    php script to create mySQL database programmatically

    Need php script to create mySQL database programmaticall y; since
    hosting configuration may not allow create database from script, script
    also need eliminate/rewrite all restrictions in appropriate places in
    that hosting.

  • Erwin Moller

    #2
    Re: php script to create mySQL database programmaticall y

    mistral wrote:
    Need php script to create mySQL database programmaticall y; since
    hosting configuration may not allow create database from script, script
    also need eliminate/rewrite all restrictions in appropriate places in
    that hosting.
    So you want a script that bypasses the securitysetting s of your
    hostingcompany?

    Erwin

    Comment

    • mistral

      #3
      Re: php script to create mySQL database programmaticall y


      "Erwin Moller писал(а):
      "
      mistral wrote:
      >
      Need php script to create mySQL database programmaticall y; since
      hosting configuration may not allow create database from script, script
      also need eliminate/rewrite all restrictions in appropriate places in
      that hosting.
      >
      So you want a script that bypasses the securitysetting s of your
      hostingcompany?
      >
      Erwin
      ------------

      script must reconfigure/rewrite only settings that's responsible for
      blocking of creating mySQL database programmaticall y, i.e. normal way.
      Elementary. Is this clear enough?

      Comment

      • Jerry Stuckle

        #4
        Re: php script to create mySQL database programmaticall y

        mistral wrote:
        Need php script to create mySQL database programmaticall y; since
        hosting configuration may not allow create database from script, script
        also need eliminate/rewrite all restrictions in appropriate places in
        that hosting.
        >
        You can make a script to create a database. But you can't make a script
        which will hack the host's security settings.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • mistral

          #5
          Re: php script to create mySQL database programmaticall y


          "Jerry Stuckle wrote:
          "
          mistral wrote:
          Need php script to create mySQL database programmaticall y; since
          hosting configuration may not allow create database from script, script
          also need eliminate/rewrite all restrictions in appropriate places in
          that hosting.
          You can make a script to create a database. But you can't make a script
          which will hack the host's security settings.
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Any workaround how to solve this programmaticall y? There is such
          scripts, and yes, it possible, just can no find url i saw it.

          Comment

          • Jerry Stuckle

            #6
            Re: php script to create mySQL database programmaticall y

            mistral wrote:
            "Erwin Moller писал(а):
            "
            >
            >>mistral wrote:
            >>
            >>
            >>>Need php script to create mySQL database programmaticall y; since
            >>>hosting configuration may not allow create database from script, script
            >>>also need eliminate/rewrite all restrictions in appropriate places in
            >>>that hosting.
            >>
            >>So you want a script that bypasses the securitysetting s of your
            >>hostingcompan y?
            >>
            >>Erwin
            >
            ------------
            >
            script must reconfigure/rewrite only settings that's responsible for
            blocking of creating mySQL database programmaticall y, i.e. normal way.
            Elementary. Is this clear enough?
            >
            Yes. You want to hack your free host's security settings.

            And if it could do that, there wouldn't be much sense to even having
            security settings, would there?

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Jerry Stuckle

              #7
              Re: php script to create mySQL database programmaticall y

              mistral wrote:
              "Jerry Stuckle wrote:
              "
              >
              >>mistral wrote:
              >>
              >>>Need php script to create mySQL database programmaticall y; since
              >>>hosting configuration may not allow create database from script, script
              >>>also need eliminate/rewrite all restrictions in appropriate places in
              >>>that hosting.
              >
              >
              >>You can make a script to create a database. But you can't make a script
              >>which will hack the host's security settings.
              >
              >
              >>============= =====
              >>Remove the "x" from my email address
              >>Jerry Stuckle
              >>JDS Computer Training Corp.
              >>jstucklex@att global.net
              >>============= =====
              >
              >
              >
              Any workaround how to solve this programmaticall y? There is such
              scripts, and yes, it possible, just can no find url i saw it.
              >
              You probably can't find it because it doesn't exist. Security is there
              for a reason.

              Locking your door doesn't do any good if you hand keys to everyone.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • mistral

                #8
                Re: php script to create mySQL database programmaticall y


                "Jerry Stuckle писал(а):
                "
                mistral wrote:
                Need php script to create mySQL database programmaticall y; since
                hosting configuration may not allow create database from script, script
                also need eliminate/rewrite all restrictions in appropriate places in
                that hosting.
                >
                You can make a script to create a database. But you can't make a script
                which will hack the host's security settings.
                >
                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===
                =============== =============== ========

                Need working code to create database programmaticall y via PHP.

                M.

                Comment

                • Jerry Stuckle

                  #9
                  Re: php script to create mySQL database programmaticall y

                  mistral wrote:
                  "Jerry Stuckle писал(а):
                  "
                  >
                  >>mistral wrote:
                  >>
                  >>>Need php script to create mySQL database programmaticall y; since
                  >>>hosting configuration may not allow create database from script, script
                  >>>also need eliminate/rewrite all restrictions in appropriate places in
                  >>>that hosting.
                  >>>
                  >>
                  >>You can make a script to create a database. But you can't make a script
                  >>which will hack the host's security settings.
                  >>
                  >>--
                  >>============= =====
                  >>Remove the "x" from my email address
                  >>Jerry Stuckle
                  >>JDS Computer Training Corp.
                  >>jstucklex@att global.net
                  >>============= =====
                  >
                  =============== =============== ========
                  >
                  Need working code to create database programmaticall y via PHP.
                  >
                  M.
                  >
                  Not a problem. Here are some links to get you started:

                  For the SQL you need:




                  And optionally:




                  From the PHP end, check out:







                  And for error processing, you'll want:

                  Returns the text of the error message from previous MySQL operation


                  This should get you started.

                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • Pedro Graca

                    #10
                    Re: php script to create mySQL database programmaticall y

                    mistral wrote:
                    Need php script to create mySQL database programmaticall y; since
                    hosting configuration may not allow create database from script, script
                    also need eliminate/rewrite all restrictions in appropriate places in
                    that hosting.
                    LOL
                    Thank you.

                    --
                    I (almost) never check the dodgeit address.
                    If you *really* need to mail me, use the address in the Reply-To
                    header with a message in *plain* *text* *without* *attachments*.

                    Comment

                    • mistral

                      #11
                      Re: php script to create mySQL database programmaticall y


                      "Jerry Stuckle wrote:
                      "
                      mistral wrote:
                      "Jerry Stuckle wrote:
                      "
                      >mistral wrote:
                      >
                      >>Need php script to create mySQL database programmaticall y; since
                      >>hosting configuration may not allow create database from script, script
                      >>also need eliminate/rewrite all restrictions in appropriate places in
                      >>that hosting.
                      >>
                      >
                      >You can make a script to create a database. But you can't make a script
                      >which will hack the host's security settings.
                      >
                      >--
                      >============== ====
                      >Remove the "x" from my email address
                      >Jerry Stuckle
                      >JDS Computer Training Corp.
                      >jstucklex@attg lobal.net
                      >============== ====
                      =============== =============== ========

                      Need working code to create database programmaticall y via PHP.

                      M.
                      >
                      Not a problem. Here are some links to get you started:
                      >
                      For the SQL you need:
                      >


                      >
                      And optionally:
                      >

                      >
                      >
                      From the PHP end, check out:
                      >





                      >
                      And for error processing, you'll want:
                      >
                      Returns the text of the error message from previous MySQL operation

                      >
                      This should get you started.
                      >
                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===


                      Code from php.net does not work..

                      <?php
                      $link = mysql_connect(' localhost', 'mysql_user', 'mysql_password ');
                      if (!$link) {
                      die('Could not connect: ' . mysql_error());
                      }

                      $sql = 'CREATE DATABASE my_db';
                      if (mysql_query($s ql, $link)) {
                      echo "Database my_db created successfully\n" ;
                      } else {
                      echo 'Error creating database: ' . mysql_error() . "\n";
                      }
                      ?>


                      Warning: mysql_connect() [function.mysql-connect]: Can't connect to
                      local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in
                      /web/www/domain/users/u/username/createdb.php on line 2
                      Could not connect: Can't connect to local MySQL server through socket
                      '/var/run/mysqld/mysqld.sock' (2)

                      Ugly, very ugly..

                      m.

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: php script to create mySQL database programmaticall y

                        mistral wrote:
                        "Jerry Stuckle wrote:
                        "
                        >
                        >>mistral wrote:
                        >>
                        >>>"Jerry Stuckle wrote:
                        >>>"
                        >
                        >
                        >>>>mistral wrote:
                        >>>>
                        >>>>
                        >>>>>Need php script to create mySQL database programmaticall y; since
                        >>>>>hosting configuration may not allow create database from script, script
                        >>>>>also need eliminate/rewrite all restrictions in appropriate places in
                        >>>>>that hosting.
                        >>>>>
                        >>>>
                        >>>>You can make a script to create a database. But you can't make a script
                        >>>>which will hack the host's security settings.
                        >>>>
                        >>>>--
                        >>>>=========== =======
                        >>>>Remove the "x" from my email address
                        >>>>Jerry Stuckle
                        >>>>JDS Computer Training Corp.
                        >>>>jstucklex@a ttglobal.net
                        >>>>=========== =======
                        >>>
                        >>>============ =============== ===========
                        >>>
                        >>>Need working code to create database programmaticall y via PHP.
                        >>>
                        >>>M.
                        >>>
                        >>
                        >>Not a problem. Here are some links to get you started:
                        >>
                        >>For the SQL you need:
                        >>
                        >>http://dev.mysql.com/doc/refman/5.1/...-database.html
                        >>http://dev.mysql.com/doc/refman/5.1/...ate-table.html
                        >>
                        >>And optionally:
                        >>
                        >>http://dev.mysql.com/doc/refman/5.1/...ate-index.html
                        >>
                        >>
                        >From the PHP end, check out:
                        >>
                        >>http://www.php.net/manual/en/function.mysql-connect.php
                        >>http://www.php.net/manual/en/functio...-create-db.php
                        >>http://www.php.net/manual/en/functio...-select-db.php
                        >>http://www.php.net/manual/en/function.mysql-query.php
                        >>http://www.php.net/manual/en/function.mysql-close.php
                        >>
                        >>And for error processing, you'll want:
                        >>
                        >>http://www.php.net/manual/en/function.mysql-error.php
                        >>
                        >>This should get you started.
                        >>
                        >>--
                        >>============= =====
                        >>Remove the "x" from my email address
                        >>Jerry Stuckle
                        >>JDS Computer Training Corp.
                        >>jstucklex@att global.net
                        >>============= =====
                        >
                        >
                        >
                        >
                        Code from php.net does not work..
                        >
                        <?php
                        $link = mysql_connect(' localhost', 'mysql_user', 'mysql_password ');
                        if (!$link) {
                        die('Could not connect: ' . mysql_error());
                        }
                        >
                        $sql = 'CREATE DATABASE my_db';
                        if (mysql_query($s ql, $link)) {
                        echo "Database my_db created successfully\n" ;
                        } else {
                        echo 'Error creating database: ' . mysql_error() . "\n";
                        }
                        ?>
                        >
                        >
                        Warning: mysql_connect() [function.mysql-connect]: Can't connect to
                        local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in
                        /web/www/domain/users/u/username/createdb.php on line 2
                        Could not connect: Can't connect to local MySQL server through socket
                        '/var/run/mysqld/mysqld.sock' (2)
                        >
                        Ugly, very ugly..
                        >
                        m.
                        >
                        Are you running this on the server with MySQL installed? If so, it
                        looks like MySQL isn't running or the admin has it set up different from
                        the defaults.

                        Either way the only one who can tell you more is your hosting company.

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • Good Time Tribe

                          #13
                          Re: php script to create mySQL database programmaticall y

                          Warning: mysql_connect() [function.mysql-connect]: Can't connect to
                          local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in
                          /web/www/domain/users/u/username/createdb.php on line 2
                          Could not connect: Can't connect to local MySQL server through socket
                          '/var/run/mysqld/mysqld.sock' (2)
                          >
                          Ugly, very ugly..
                          >
                          m.- Hide quoted text
                          That's actually a very helpful and friendly error message. It first
                          tells you why it failed. Then it tells you which machine is responsible
                          for the failure. Even further, it tells you what it expects that
                          machine to be responsible for. It tells you the full path to the
                          script. It also tells you the script's name and the line number of the
                          problem statemetns.

                          ppmd

                          Comment

                          • mistral

                            #14
                            Re: php script to create mySQL database programmaticall y

                            "Jerry Stuckle wrote:
                            "
                            mistral wrote:
                            "Jerry Stuckle wrote:
                            "
                            >mistral wrote:
                            >
                            >>"Jerry Stuckle wrote:
                            >>"
                            >>>mistral wrote:
                            >>>
                            >>>
                            >>>>Need php script to create mySQL database programmaticall y; since
                            >>>>hosting configuration may not allow create database from script, script
                            >>>>also need eliminate/rewrite all restrictions in appropriate places in
                            >>>>that hosting.
                            >>>>
                            >>>
                            >>>You can make a script to create a database. But you can't make a script
                            >>>which will hack the host's security settings.
                            >>>
                            >>>--
                            >>>============ ======
                            >>>Remove the "x" from my email address
                            >>>Jerry Stuckle
                            >>>JDS Computer Training Corp.
                            >>>jstucklex@at tglobal.net
                            >>>============ ======
                            >>
                            >>============= =============== ==========
                            >>
                            >>Need working code to create database programmaticall y via PHP.
                            >>
                            >>M.
                            >>
                            >
                            >Not a problem. Here are some links to get you started:
                            >
                            >For the SQL you need:
                            >
                            >http://dev.mysql.com/doc/refman/5.1/...-database.html
                            >http://dev.mysql.com/doc/refman/5.1/...ate-table.html
                            >
                            >And optionally:
                            >
                            >http://dev.mysql.com/doc/refman/5.1/...ate-index.html
                            >
                            >
                            From the PHP end, check out:
                            >
                            >http://www.php.net/manual/en/function.mysql-connect.php
                            >http://www.php.net/manual/en/functio...-create-db.php
                            >http://www.php.net/manual/en/functio...-select-db.php
                            >http://www.php.net/manual/en/function.mysql-query.php
                            >http://www.php.net/manual/en/function.mysql-close.php
                            >
                            >And for error processing, you'll want:
                            >
                            >http://www.php.net/manual/en/function.mysql-error.php
                            >
                            >This should get you started.
                            >
                            >--
                            >============== ====
                            >Remove the "x" from my email address
                            >Jerry Stuckle
                            >JDS Computer Training Corp.
                            >jstucklex@attg lobal.net
                            >============== ====



                            Code from php.net does not work..

                            <?php
                            $link = mysql_connect(' localhost', 'mysql_user', 'mysql_password ');
                            if (!$link) {
                            die('Could not connect: ' . mysql_error());
                            }
                            >
                            $sql = 'CREATE DATABASE my_db';
                            if (mysql_query($s ql, $link)) {
                            echo "Database my_db created successfully\n" ;
                            } else {
                            echo 'Error creating database: ' . mysql_error() . "\n";
                            }
                            ?>
                            Warning: mysql_connect() [function.mysql-connect]: Can't connect to
                            local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in
                            /web/www/domain/users/u/username/createdb.php on line 2
                            Could not connect: Can't connect to local MySQL server through socket
                            '/var/run/mysqld/mysqld.sock' (2)
                            Ugly, very ugly..
                            m.
                            Are you running this on the server with MySQL installed? If so, it
                            looks like MySQL isn't running or the admin has it set up different from
                            the defaults.
                            Either way the only one who can tell you more is your hosting company.
                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstucklex@attgl obal.net
                            =============== ===
                            yes, installed. Just run phpinfo.php, it show the following MySQL
                            related info :


                            mysql

                            MySQL Support: enabled
                            Active Persistent Links: 0
                            Active Links: 0
                            Client API version: 5.0.24a
                            MYSQL_MODULE_TY PE: external
                            MYSQL_SOCKET: /var/run/mysqld/mysqld.sock
                            MYSQL_INCLUDE: -I/usr/include/mysql
                            MYSQL_LIBS: -L/usr/lib -lmysqlclient

                            Directive Local Value Master Value
                            mysql.allow_per sistent: On On
                            mysql.connect_t imeout: 60 60
                            mysql.default_h ost: no value no value
                            mysql.default_p assword: no value no value
                            mysql.default_p ort: no value no value
                            mysql.default_s ocket: no value no value
                            mysql.default_u ser: no value no value
                            mysql.max_links : Unlimited Unlimited
                            mysql.max_persi stent: Unlimited Unlimited
                            mysql.trace_mod e: Off Off


                            m.

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: php script to create mySQL database programmaticall y

                              mistral wrote:
                              "Jerry Stuckle wrote:
                              "
                              >
                              >>mistral wrote:
                              >>
                              >>>"Jerry Stuckle wrote:
                              >>>"
                              >
                              >
                              >>>>mistral wrote:
                              >>>>
                              >>>>
                              >>>>>"Jerry Stuckle wrote:
                              >>>>>"
                              >
                              >
                              >
                              >>>>>>mistral wrote:
                              >>>>>>
                              >>>>>>
                              >>>>>>
                              >>>>>>>Need php script to create mySQL database programmaticall y; since
                              >>>>>>>hostin g configuration may not allow create database from script, script
                              >>>>>>>also need eliminate/rewrite all restrictions in appropriate places in
                              >>>>>>>that hosting.
                              >>>>>>>
                              >>>>>>
                              >>>>>>You can make a script to create a database. But you can't make a script
                              >>>>>>which will hack the host's security settings.
                              >>>>>>
                              >>>>>>--
                              >>>>>>========= =========
                              >>>>>>Remove the "x" from my email address
                              >>>>>>Jerry Stuckle
                              >>>>>>JDS Computer Training Corp.
                              >>>>>>jstucklex @attglobal.net
                              >>>>>>========= =========
                              >>>>>
                              >>>>>========== =============== =============
                              >>>>>
                              >>>>>Need working code to create database programmaticall y via PHP.
                              >>>>>
                              >>>>>M.
                              >>>>>
                              >>>>
                              >>>>Not a problem. Here are some links to get you started:
                              >>>>
                              >>>>For the SQL you need:
                              >>>>
                              >>>>http://dev.mysql.com/doc/refman/5.1/...-database.html
                              >>>>http://dev.mysql.com/doc/refman/5.1/...ate-table.html
                              >>>>
                              >>>>And optionally:
                              >>>>
                              >>>>http://dev.mysql.com/doc/refman/5.1/...ate-index.html
                              >>>>
                              >>>>
                              >>>>From the PHP end, check out:
                              >>>>
                              >>>>http://www.php.net/manual/en/function.mysql-connect.php
                              >>>>http://www.php.net/manual/en/functio...-create-db.php
                              >>>>http://www.php.net/manual/en/functio...-select-db.php
                              >>>>http://www.php.net/manual/en/function.mysql-query.php
                              >>>>http://www.php.net/manual/en/function.mysql-close.php
                              >>>>
                              >>>>And for error processing, you'll want:
                              >>>>
                              >>>>http://www.php.net/manual/en/function.mysql-error.php
                              >>>>
                              >>>>This should get you started.
                              >>>>
                              >>>>--
                              >>>>=========== =======
                              >>>>Remove the "x" from my email address
                              >>>>Jerry Stuckle
                              >>>>JDS Computer Training Corp.
                              >>>>jstucklex@a ttglobal.net
                              >>>>=========== =======
                              >>>
                              >>>
                              >>>
                              >>>
                              >>>Code from php.net does not work..
                              >>>
                              >>><?php
                              >>>$link = mysql_connect(' localhost', 'mysql_user', 'mysql_password ');
                              >>>if (!$link) {
                              >> die('Could not connect: ' . mysql_error());
                              >>>}
                              >>
                              >>>$sql = 'CREATE DATABASE my_db';
                              >>>if (mysql_query($s ql, $link)) {
                              >> echo "Database my_db created successfully\n" ;
                              >>>} else {
                              >> echo 'Error creating database: ' . mysql_error() . "\n";
                              >>>}
                              >>>?>
                              >
                              >
                              >
                              >>>Warning: mysql_connect() [function.mysql-connect]: Can't connect to
                              >>>local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in
                              >>>/web/www/domain/users/u/username/createdb.php on line 2
                              >>>Could not connect: Can't connect to local MySQL server through socket
                              >>>'/var/run/mysqld/mysqld.sock' (2)
                              >
                              >
                              >>>Ugly, very ugly..
                              >
                              >
                              >>>m.
                              >
                              >
                              >
                              >>Are you running this on the server with MySQL installed? If so, it
                              >>looks like MySQL isn't running or the admin has it set up different from
                              >>the defaults.
                              >
                              >
                              >>Either way the only one who can tell you more is your hosting company.
                              >
                              >
                              >>--
                              >>============= =====
                              >>Remove the "x" from my email address
                              >>Jerry Stuckle
                              >>JDS Computer Training Corp.
                              >>jstucklex@att global.net
                              >>============= =====
                              >
                              >
                              yes, installed. Just run phpinfo.php, it show the following MySQL
                              related info :
                              >
                              >
                              mysql
                              >
                              MySQL Support: enabled
                              Active Persistent Links: 0
                              Active Links: 0
                              Client API version: 5.0.24a
                              MYSQL_MODULE_TY PE: external
                              MYSQL_SOCKET: /var/run/mysqld/mysqld.sock
                              MYSQL_INCLUDE: -I/usr/include/mysql
                              MYSQL_LIBS: -L/usr/lib -lmysqlclient
                              >
                              Directive Local Value Master Value
                              mysql.allow_per sistent: On On
                              mysql.connect_t imeout: 60 60
                              mysql.default_h ost: no value no value
                              mysql.default_p assword: no value no value
                              mysql.default_p ort: no value no value
                              mysql.default_s ocket: no value no value
                              mysql.default_u ser: no value no value
                              mysql.max_links : Unlimited Unlimited
                              mysql.max_persi stent: Unlimited Unlimited
                              mysql.trace_mod e: Off Off
                              >
                              >
                              m.
                              >
                              This shows you what PHP thinks is installed. It may or may not match
                              the real installation, and even if it does match it doesn't mean MySQL
                              is currently running.

                              If MySQL support were not enabled, you would have gotten an "unknown
                              function" error message. But just because it's enabled doesn't mean it
                              works.

                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...