Jump to content

Recommended Posts

Posted

To develop my database, I installed Apache & MYSQL on my computer. Since I am still developing the site, I frequently recreate, and change the table structure using the following commands after deleting the database.

 

mysqladmin -u username -ppassword create databasename

mysql -u username -ppassword<filename.sql

mysqlimport -L -h localhost -u username -ppassword --fields-terminated-by="|" databasename c:/directory/tables/filename.txt

 

...

 

Is it possible for me to use this method of table construction on the server?

 

Thanks

Posted

These are all commands that are run from a shell prompt. You would not be able to run these commands directly on the server, as TCH does not provide shell access.

 

...I frequently recreate, and change the table structure using the following commands after deleting the database.

Rather than deleting and recreating your database, you might want to run a query to drop all of the database tables instead. This would leave your database intact and you would not have to create it again.

 

mysqladmin -u username -ppassword create databasename

This command creates a database. You would have to do this from the "MySQL Databases" page in CPanel (you cannot create a database in phpMyAdmin).

 

mysql -u username -ppassword<filename.sql

You can use phpMyAdmin to import and run queries stored in a file such as this. On the left side of the phpMyAdmin page, click the middle icon ("SQL") to open a query popup window. There is a "Import Files" tab in this popup window where you can specify a file to be uploaded and imported into your MySQL database.

 

mysqlimport -L -h localhost -u username -ppassword --fields-terminated-by="|" databasename c:/directory/tables/filename.txt

This command would need to be run as a LOAD DATA INFILE query in phpMyAdmin.

 

Hope this helps...

Posted

I created the database using cpanel.

 

Created a user with permissions.

 

Created an sql to create tables in the database

 

Example of code in sql:

 

Create Table tablename(

field1_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,

field2_id SMALLINT UNSIGNED,

field3 VARCHAR(200)

);

 

Imported file and executed it

 

All tables were created perfectly.

 

Then I tried to add data to the table by creating a file contaning the following code.

 

LOAD DATA LOCAL INFILE 'c:dir\on\my\computer.txt' INTO TABLE logonname_databasename.tableName FIELDS TERMINATED BY '|';

 

 

Save file and imported it.

 

No error message in red appeared. Rather the following statements

 

Inserted rows: -1 (Query took 0.0070 sec)

SQL-query: LOAD DATA LOCAL INFILE 'c:dir\on\my\computer.txt' INTO TABLE logonname_databasename.tableName FIELDS TERMINATED BY '|'

 

No data was added to the table and yet no error message appeared.

 

I checked and verified that 'c:dir\on\my\computer.txt' exist and contains data.

 

Any suggestions on where I am going astray.

Posted

I created the database using cpanel.

 

Created a user with permissions.

 

Created an sql to create tables in the database

 

Example of code in sql:

 

Create Table tablename(

field1_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,

field2_id SMALLINT UNSIGNED,

field3 VARCHAR(200)

);

 

Imported file and executed it

 

All tables were created perfectly.

 

Then I tried to add data to the table by creating the following sql.

 

LOAD DATA LOCAL INFILE 'c:dir\on\my\computer.txt' INTO TABLE logonname_databasename.tableName FIELDS TERMINATED BY '|';

 

Imported file and executed it

 

No error message in red appeared. Rather the following statements

 

Inserted rows: -1 (Query took 0.0070 sec)

SQL-query: LOAD DATA LOCAL INFILE 'c:dir\on\my\computer.txt' INTO TABLE logonname_databasename.tableName FIELDS TERMINATED BY '|'

 

No data was added to the table and yet no error message appeared.

 

I checked and verified that 'c:dir\on\my\computer.txt' exist and contains data.

 

Any suggestions on where I am going astray.

Posted

From the MySQL documentation on LOAD DATA INFILE:

If the LOCAL keyword is specified, it is interpreted with respect to the client end of the connection:

When using phpMyAdmin, the 'client' end of the connection is the TCH server, as phpMyAdmin runs on the TCH server. You'd need to upload the file to the server, then run the LOAD DATA INFILE query specifying a server path to the file (/home/cpanelName/someDir/computer.txt).

 

To run a LOAD DATA INFILE query and be able to specify a file on your machine, you'd need to have a MySQL client running on your machine (such as phpMyAdmin installed on locally on your web server, or MySQL Query Browser), plus enable remote MySQL access on your account.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...