WordPress 3.5.1
WP-DBManager 2.63
Database Type MYSQL
Database Version v5.1.68-cll
Trying to create new table on database for WordPress site using the WP-DBManager plugin.
I click on the Run SQL Query link in the Admin panel and paste in my query which is
CREATE TABLE mg_msl_lookup
(
device_id INT(11) NOT NULL auto_increment,
sku VARCHAR(30) NOT NULL,
manufacturer VARCHAR(30) NOT NULL,
phone VARCHAR(50) NOT NULL,
esn BIGINT(18) NOT NULL,
msl INT(6) NOT NULL
);
I click Run and I get the error message
CREATE TABLE mg_msl_lookup
0/1 Query(s) Executed Successfully
So I did a google search for "WP-Dbmanager 0/1 Query(s) Executed Successfully" and found this forum post on the plugin developer's site. It suggested to put the statement all on one line, so I did:
CREATE TABLE mg_msl_lookup (Device_Id int(11) NOT NULL AUTO_INCREMENT, SKU varchar(30) NOT NULL, Manufacturer varchar(30) NOT NULL, Phone varchar(50) NOT NULL, ESN bigint(18) NOT NULL, MSL int(6) NOT NULL);
Once again I click Run and I get the error message:
CREATE TABLE mg_msl_lookup (Device_Id int(11) NOT NULL AUTO_INCREMENT, SKU varchar(30) NOT NULL, Manufacturer varchar(30) NOT NULL, Phone varchar(50) NOT NULL, ESN bigint(18) NOT NULL, MSL int(6) NOT NULL);
0/1 Query(s) Executed Successfully
I have site wide admin permissions, I can drop/empty tables using the plugin GUI, but for some reason can't create a simple table. I have 40 tables before and after I run the statement.
The plugin developer has these set of instructions on the Run Query page
CREATE statement will return an error, which is perfectly normal due to the database class. To confirm that your table has been created check the Manage Database page.
UPDATE statement may return an error sometimes due to the newly updated value being the same as the previous value.
ALTER statement will return an error because there is no value returned.
I'm gathering that what he means in #1 is that when you run a CREATE statement it will error (so perhaps 0/1 Query(s) Executed Successfully is normal?) so I followed the directions and go back to the Manage Database page but my new table is not there.
Does anyone have any experience with the WP-DBManager that could assist with this ? This is getting rather frustrating.
I opted to use phpMyAdmin to create the tables instead of the plugin, worked like a charm.
Related
I've encountered an issue while assisting someone with their legacy web application that's being hosted on Apache Tomcat with a SQL DB. Most of the user accounts on the DB that has access to the web application has been locked out due to max login attempts. To make things worse, they do not remember the passwords; including the admin accounts access that is able to make resets via the web app. I'm trying to either A) Create a new admin account in the table to get admin access back to the webapp for them or B) Recover their passwords and reduce the login attempt limits that have cause majority of them to be locked out. Really stuck from here and not sure where to progress.
This is what I've done:
I've looked up the SQL User Tables to ascertain if I can see their passwords in plain text. However, the password columns are ciphered in someway. From the only user that has access to the web app. We confirmed that passwords are alphanumerical - but on the tables the register as numericals like:
-1662545724
I had also checked if the table creation has some sort of hashing or salt did not show anything. This was the output:
CREATE TABLE user (
userID int(10) unsigned NOT NULL auto_increment,
userName varchar(100) NOT NULL,
password varchar(100) NOT NULL,
name varchar(255) NOT NULL,
initials varchar(20) NOT NULL,
tries int(10) unsigned NOT NULL,
firstLogin tinyint(1) NOT NULL,
roleID int(10) unsigned NOT NULL,
createdBy varchar(100) NOT NULL,
createdDate date NOT NULL,
createdTime time NOT NULL,
modifiedBy varchar(100) NOT NULL,
modifiedDate date NOT NULL,
modifiedTime time NOT NULL,
PRIMARY KEY (userID),
KEY FK_user_roleID (roleID),
CONSTRAINT FK_user_roleID FOREIGN KEY (roleID) REFERENCES role (roleID)
) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=latin1;
The user table insert is as shown below. Only 1 singular account is currently active amongst about a 100. We have a plaintext password for it and this password is reflected as its ciphered text in point 1 - Will it be possible to simply duplicate the line, change the username and elevate the roleID to get a new admin user to the web app?
(userID,userName,password,name,initials,tries,firstLogin,roleID,createdBy,createdDate,createdTime,modifiedBy,modifiedDate,modifiedTime)
Will only get access to the server again tomorrow. In the mean time i do have a complete backup of the SQL file only. Seek your kind advices on how i can solve this issue.
I try do create a simple mysql database with Flyway migration, but it doesn't going well.
I have created my .sql it named as V1_0__init.sql and I've written some sql commands there:
CREATE TABLE User (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
created DATE NOT NULL,
username varchar(15) NOT NULL,
password varchar(15) NOT NULL,
email varchar(40) NOT NULL,
status boolean NOT NULL,
unique(username)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I think it should be fine, but I have two errors, one at the first line (CREATE TABLE) and another at the fourth line (created DATE NOT NULL).
The error message says:
Invalid or Incomplete statement
Expected one of the following: ALGORITHM DEFINER SQL VIEW
(At the 'created DATE NOT NULL' line have a similar message, the only difference is this: Algoritm definer OR sql view)
I've tried to fix these but it didn't go well.
Anyone could help me how to fix this?
Maybe did I miss something? Should I do something in application.properties?
I have database which works on MySql. And i need to copy it to another computer where there is only management studio. i create .sql file from MySql and tried to run it in studio but always have syntax errors.
How to do it correctly?
CREATE TABLE branches (
idbranches int(11) NOT NULL AUTO_INCREMENT,
address varchar(200) NOT NULL,
e.g. incorrect syntax for "AUTO_INCREMENT"
The SQL Server syntax is:
CREATE TABLE branches (
idbranches int identity(1, 1) not null,
address varchar(200) NOT NULL
);
I've been doing a lot of new learning about MySQL and triggers. I think I understand the concept and I realise there are a LOT of possible dangers in using them. However I believe the limited use of them is correct for the function I want to perform.
I have 9 tables which correspond to 9 different web based Ajax engined forms. I've worked hard on these, being my first time using Ajax, and I'm reasonably happy with them. Each time a user makes a change to whichever form they are filling out, the change is Ajaxed back to the DB and they get a confirmation or error response. Fairly straight forward. Each forms respective table has a "status" field, a "lastModified" field and a field I call "agRef" which is sort of like status but is null until the form reaches a certain stage, further along the process.
I have an additional table called "records" which is where all entries in any of the other tables, is listed so we can easily see what forms have been started, when their last changes were made and what status's they have. So here is where I believe the trigger part should work, so that I don't have to make updates to the "records" table in my php on every single transaction.
The "records" table is set out like this:
`uaID` int(11) NOT NULL AUTO_INCREMENT,
`uID` int(11) NOT NULL,
`appNo` int(11) NOT NULL,
`applicationKey` varchar(8) NOT NULL,
`appID` int(11) DEFAULT NULL,
`applicationName` varchar(64) NOT NULL,
`agRef` varchar(32) DEFAULT NULL,
`status` varchar(32) NOT NULL,
`dateStarted` int(11) NOT NULL,
`lastModified` int(11) NOT NULL,
Now all of these fields are populated at the same time the matching entry is inserted into which ever one of the other 9 tables the form connects to. A small example of one of the other 9 tables would look like this:
`appID` int(11) NOT NULL AUTO_INCREMENT,
`uID` int(11) NOT NULL,
`uaID` int(11) NOT NULL,
`status` varchar(32) NOT NULL DEFAULT 'Data Acquisition',
`agRef` varchar(32) DEFAULT NULL,
`groupName` varchar(64) DEFAULT NULL,
`shortTitle` varchar(64) DEFAULT NULL,
`recipient` varchar(64) DEFAULT NULL,
`partOfValCh` varchar(64) DEFAULT NULL,
`sector` varchar(64) DEFAULT NULL,
`subSector` varchar(64) DEFAULT NULL,
`topic` varchar(64) DEFAULT NULL,
<snip because this can go on for a lot of lines>
`dateStarted` int(11) NOT NULL,
`lastModified` int(11) NOT NULL,
agRef on both tables remain null for now, appID is null on the records table initially at the point of creation but is updated immediately as soon as the corresponding entry is made into the second table, where it is generated by auto increment and then a call is made back to my records table to insert the appID there.
The three things that will change from any of the data tables are the three fields "status", "agRef", "lastModified".
So I'm trying to create a trigger that will do this after each alteration/update to the data table, so that the data in my records table is consistent and accurate.
This is my first ever trigger set up attempt:
DELIMITER $$
CREATE TRIGGER `dataTableOne_to_records_sync` AFTER UPDATE ON `dataTableOne`
FOR EACH ROW BEGIN
UPDATE records (agRef, status, lastModified) VALUES (NEW.agRef, NEW.status, NEW.lastModified) WHERE appID = OLD.appID;
END$$
DELIMITER ;
I am trying to set this up through phpmyadmin, but it is returning an error telling me I have a syntax problem within my UPDATE line. I feel that it is an issue with the WHERE part - the appID is the one common element that ties the row in "records" to the row being updated/changed in "dataTableOne". How do I set this up correctly? Is my error something more serious, and am I running the risk of creating a huge mess, like a never ending loop? I'm a bit paranoid about doing this for the first time. Thanks in advance for help and advice.
UPDATE I have now tried a few other trigger attempts but although MySQL will accept them as being valid trigger syntax, they always seem to break the entire DB functionality. Can anyone help me with my trigger syntax to get it to work correctly? In the demo tables above, if the SECOND table gets updated at all, I want the three fields copied over into the FIRST table by the trigger. The three values I want copied across are "status", "agRef", and "lastModified".
My most recent failed attempt was this:
CREATE TRIGGER AIGltInq_sync AFTER INSERT ON app_AIGltInq
FOR EACH ROW
UPDATE records r
SET r.agRef = NEW.agRef
, r.status = NEW.status
, r.lastModified = NEW.lastModified
WHERE uaID = NEW.uaID;
I'm not at all familiar with that form of the UPDATE statement.
To change values of columns in rows, we'd typically write an UPDATE statement like this:
UPDATE records r
SET r.agRef = NEW.agRef
, r.status = NEW.status
, r.lastModified = NEW.lastModified
WHERE r.appId = OLD.appID
Reference: https://dev.mysql.com/doc/refman/5.5/en/update.html
Question withdrawn. Triggers are seriously best to avoid, as they tend to cause more breakages than they fix! Most recommendations tend towards handling the function with whatever scripting language you are using to talk with the DB. In my case this is PHP and PHP is now performing all of the functionality I was hoping to short-cut by using triggers. Lesson? Don't take short-cuts when wanting to do the job right. :)
Sorry to bother you again with my questions.
I need to create a trigger in mysql to change the rows of a table.
The idea is the following:
Whenever I create a new task it will automatically create the status.
If StartDate = NULL -> status = Planning
If have endDate -> status =completed
If Have StartDate -> status =In Progress
If current date > dateBeginPrevision ->status = Overdue
Does anyone could help me please?
I dont I ask to hear the trigger, only that would give me a little help to get there, because I am a noob in mysql.
Thank you all very much.
CREATE TABLE `tasks` (
`idTask` varchar(45) NOT NULL,
`descTask` varchar(45) DEFAULT NULL,
`dateBeginPrevision` varchar(45) DEFAULT NULL,
`startDate` varchar(45) DEFAULT NULL,
`endDate` varchar(45) DEFAULT NULL,
`Priority` varchar(45) NOT NULL,
`status` varchar(45) DEFAULT NULL,
PRIMARY KEY (`idTask`)
)
----------EDIT--------------
After this comment: "I dont think you should use trigger here, because trigger is a monitor of table, when the source table has some changes on it (insert, delete ,update)"
I chose to do this kind of checking through the java language, ie directly in my application without relying on the capabilities of the database.
Thank you.
I dont think you should use trigger here, because trigger is a monitor of table, when the source table has some changes on it (insert, delete ,update), it would invoke the trigger on it, and now ,what's your source table?