1

I don't know much about programming, so I hired someone to create a simple MySQL database with an online form that I can enter information into.

I already setup the MySQL database at my hosting account and gave the programmer the login details as well as an FTP account.

He says he needs my hosting username/password in order to create the database because he needs to use PHPMyadmin to create the tables and test the database.

This seems kinda shady to me. Can't the programmer create the tables using PHP commands alone? I don't want to give out my main username/password to a stranger.

I'm hosted at 1and1.com if that matters any

2
  • Yes, the tables can be created via PHP, if the user you have assigned to the created Database has the CREATE, ALTER, etc... privileges. If the programmer doesn't know how, then think again about the choice you made.
    – Shef
    Jul 28, 2011 at 16:47
  • 1
    Yes he can create the tables using PHP. Maybe you can change the password/username for phpMyAdmin and give him the changed credentials. After he is done, just change it back.
    – Jacob
    Jul 28, 2011 at 16:48

6 Answers 6

2

If you give the MySQL user sufficient database permissions, they can use the CREATE TABLE statement to create the tables without having to use PHPMyadmin. If they don't know how to create tables without using the GUI, then I would be suspicious of their overall database programming abilities as being the lead on your project.

2
  • They'll still need a UN/pass to do it, whether it's PHPmyAdmin or via PHP.
    – ceejayoz
    Jul 28, 2011 at 16:48
  • The credentials for using CREATE TABLE would be the database account for doing the permissions. To access PHPmyAdmin, the programmer is probably talking about the OP's 1and1 hosting username/password to be able to access the interface.
    – scwagner
    Jul 28, 2011 at 16:49
1

PHP can execute any SQL statement on a MySQL server which it has a valid connection too, including the CREATE TABLE command, however, these will be subject to the "privileges" of the user that PHP used to gain the MySQL connection.

The MySQL user that you provided the login credentials for may not have create table privileges. In this case, PHP could do nothing, as the SQL commands executed would fail.

That said, I don't know why your hosting username/password would be needed to use PHPMyAdmin. Usually a login to PHPMyAdmin is done with the MySQL user, not the hosting user. Though, that user would be subject to the same privilege restrictions, so we're back at part 1:

  • Does the MySQL user you created for the programmer have create table privileges?

    If yes, they should be able to create tables from PHP alone, and if you have PHPMyAdmin installed, they should be able to log in using that same user already (and not your hosting user!)

    If no (probably unlikely, though I don't know 1and1), then you will need to provide a MySQL user that does have create table privileges before they can do anything; then see above.

0

It's possible to submit the necessary CREATE TABLE queries via php to the database, but the developer is likely more familiar with the way PHPMyAdmin displays what is set up on the server.

2
  • CREATE TABLE queries (and any other SQL queries) will require a database connection, which will require a username and password anyways.
    – ceejayoz
    Jul 28, 2011 at 16:48
  • You are correct. I am making a distinction between the database credentials and the hosting account credentials, which would allow access to general account administration.
    – Ryan
    Jul 28, 2011 at 16:50
0

Sounds viable to me. Technically he can do everything with PHP alone, but it is much much easier to use PHPMyAdmin.

I think you should hire someone you can trust and give them the tools to help them do a good job.

0

You don't have to give him your user/pass. You can create a new user in PHPMyAdmin, with less privileges. When he finishes installing your database, just delete that user.

Yes, he can create databases using only PHP, but it is slower than just use PHPMyAdmin.

Probably the person you hired is not very skilled in software development and the only way he know for modifying MySQL is using that web interface.

1
  • I'm starting to think 1&1 puts phpMyAdmin itself behind a login wall.
    – ceejayoz
    Jul 28, 2011 at 17:05
0

You can do it this way:

http://www.w3schools.com/php/php_mysql_create.asp

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }

// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?> 

I might also create a DBUser that has access to the database and tell him to download a mySQL client (such as HediSQL) to do his database work. Then after they are done, just remove the DBUser (or take away all permissions).

4
  • This is dependent on too many variables (hosting and database setup) to be a sufficient answer.
    – Nicole
    Jul 28, 2011 at 16:50
  • How is that a downvote? He asked if it can be done. My answer was, "it can". I also gave an alternative as well using a DB User.
    – webdad3
    Jul 28, 2011 at 16:53
  • Yeah, you answered the title, but given your answer, you might as well have not read the rest of the question.
    – Nicole
    Jul 28, 2011 at 16:56
  • We must have very differing views on the question then. He doesn't want to give the programmer his usr/pwd to the control panel. That is fine, my second part of the answer, is directed to alternatives.
    – webdad3
    Jul 28, 2011 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.