PDA

View Full Version : How do I run a command in phpMyAdmin?


turtle
2008-09-05, 22:26
I have to enter two commands:
CREATE INDEX Index_FK_Trips_ID ON positions( FK_Trips_ID )
CREATE INDEX Index_FK_Users_ID ON positions( FK_Users_ID )
for an app on my phone and I have no idea how to run these lines of code. I don't want to screw up the DB since I also don't know how to backup and restore MySQL.

Can someone please help me with this? I don't mind reading links, but everything I've come up with in Google is way over my head or not related to what I'm trying to do. Thanks for any help. :)

Banana
2008-09-05, 22:36
why not just use MySQL's CLI client and be done with it?

As for backup, take a look at mysqldump, which creates a .sql file of the database so it's quite simple to dump everything into a file, then if it goes south, it's just a command line away:

shell> cd MyDirectoryWhereSQLFileIs
shell> mysql -u Me -p
password:

Welcome to MySQL!

mysql> Use MyDatabase;
Database changed

mysql> source mysqldump.sql
<several SQL statements afterwad>

HTH.

turtle
2008-09-05, 22:46
Ok, I did manage to figure out how to export my DB into a .sql file. So it should be baked up now. (I've never done this before. Bad idea I know.)

I'd love to do a CLI change other than I don't know how to access it via CLI. It's a web host and I'm not sure I have CLI access. They use cPanel and phpMyAdmin is the DB tool we get. I'll look into the CLI though.

Banana
2008-09-05, 22:52
Well, if it's managed by hosting company, it may be subject to their security policy.

If they do allow CLI, which I doubt, you can do this:

mysql -h <server IP address> -u <username> -d <database> -p

(Of course, you need to have MySQL CLI installed on your computer.

Can you tell that I've never used phpMyAdmin? :o

turtle
2008-09-05, 23:01
I've looked through my cPanel and see nothing about CLI access.

So If I play around and make changes on this DB and kill it, all I'd have to do is import the .sql I exported and it'll be back as it was once I started this right?

Banana
2008-09-05, 23:04
Yep. Well, to be safe, you need to make sure that .sql file includes *both* definition and structure.

You can open the .sql file with a text editor, read few lines and see if there are any actual data being inserted into it after so many lines creating/altering tables.

HTH.

turtle
2008-09-05, 23:24
Yes, you've been very helpful. I've seen both structure and content in the file. I know the content so I'm comfortable it's all there. Now I guess I'll just play around and see if I can figure it out.

turtle
2008-09-06, 00:47
I got it working. Thanks for the support Banana. :)

I'm not sure of exactly what I did, but those keys are now visible in my export.