Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have mysql, apache, php, and webmin installed on my machine and would like to create a new mysql database with webmin. I go to create a new database and from there i am lost... Can someone point me in the right direction to get this new database created. I want to be able to have a site that will enter information and pull information back from this database with php.
That is a pretty broad question. Let me see if I can get you going a bit.
First off you have to create the database, which I think you did already then you have to create a table in the database with fields like:
id
data_name
data
Then you have to set up a user that is allowed to connect to that database, this is all easly done from webmin.
You could then use php to add and display the data from the database. This is the hard part, you might want to check out a book on php or find a online manual for this.
You're right, that is a broad question... I will try to narrow it down. From webmin I click create database, it brings up a 'New database options' dialog. This is where it starts getting a little fuzzy, 'Database Name (that i can understand), 'Initial Table = none', 'Initial Table Structure' - not sure what these options are. I am new to databases and unfamiliar with their terminology. I still don't think I've actually asked a question but I knew this was the best place to start.
Ok we can work with that, I will start here and see where it goes.
1st. Go into webmin and click on create database put in the name you want for the database and click none on the intial table and don't fill out the rest click create.
Then you have to decide what data you are putting into the database. for a simple one that holds employee addresses you would click on the database you just created and click create new table, you will have to put in how many fields you want in it, for our address's table there would be 4
id - type will be "int" width will be 4
name - type will be "varchar" widht will be 60
address - type will be "varchar" width will be 100
phone - type will be "varchar" width will be 15
you will put in the fields shown above into the new table and then click create table, this is now a database that is ready to accept data.
Now you should never access a normal database as the root database user so you need to create a mysql user in webmin, this is done the same place that you created the database. Click on on user permissions then create new user, give them a username and a password and set the hosts to localhost don't give them any permissions.
Save that user and then go to database permissions, (same places as add new database and users) and click create new database permissions. Select your new database. then type in the username you just created and set the hosts to localhost. Give them full permissions, (select all the options from the list) and then save that.
You will now have a working database with a user set up to access it. whew.
After reading this post and what you have running it occured to me that you might be trying to setup phpnuke or postnuke. If this is the case, then follow the instructions that cli_man posted, except that these programs have built in scripts to create the tables for you.
If not, and you are writing your own php script that you want to use mysql then ignore what I am saying and do everything that he posted.
From his origanol questions I took that he wanted to set up the database and programming from scratch. But if he is trying to install a php program that needs mysql support he would not have to worry about creating the tables just the database and permissions like I said above.
Cli_man you are correct I am trying to set this up from scratch. I followed your instructions on the database side and all worked well. Now I have some php code that I got from somewhere else with someone trying to do basically the same as me. However it does not work for me, any suggestions, below is the code, thanks in advance.
<?
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * From Customer_Information WHERE Title like '%Customer%'";
$result=mysql_query($query) or die (mysql_error());
while ($row=mysql_fetch_array($result))
{
echo $row['fieldname'];
}
You might be running into a register_globals problem. I didn't think of that, all of my programming has been done with register_globals set to on and the default now is off, you can check by making a php file that only has this in it:
<? phpinfo() ?>
Then go to that page and see if register_globals is set to on or off. Post back what you find.
Ok, I think that may be the problem with the script I gave you. You have to access variables differently when the register_globals is off, I haven't gotten into that yet because I haven't had the time. For now if you want you could turn it to on (sidenote This makes your scripts less secure)
To turn it to on find you php.ini file and find where it says register_globals and change it from off to on, save the file and restart apache. Then that script should work for you.
And just to say again what I did above, it is a good thing to have register_globals set to off, I just don't know how to program with it that way yet.
I turned globals on and it still doesn't connect. It is still failing on line 7, couldn't connect. Maybe a database permissions problem?? I've deleted and started over with a new database but still doesn't work.
A couple of things I didn't notice before, in the script you pasted above on line 7 you need a space after the , after localhost and db_user Also on line 8 you need to have or die not just or
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.