简体   繁体   中英

Cannot create a stored procedure using MySQL

So this may be a little vague but I'm running into layer after layer of problems here. Each "fix" I find on Google presents me with another problem. Laying things out anyway, I've bought a Windows hosting package in order to produce an asp.net application backed by a MySQL server. I'm used to MSSQL but this should be workable and is nicer for open source.

The first problem I noticed was that my (recently installed) copy of MySQL Workbench with MySQL Server 5.7 will not let me connect to my DB whatsoever. Tables refuse to load and I am greeted with: #1548 - Cannot load from mysql.proc. The table is probably corrupted

From there, I thought "ok that's fine, I'll just use the web admin tool" which in this case is phpMyadmin . I have zero experience with phpMyadmin in the past but it looks ok and is preinstalled in this control panel. I started off by creating my first 5 tables. That went smoothly and I now have 5 tables in the database, one of them even has some data which I may view by running "SELECT * FROM Account_Type".

All seems good, so I go to create a procedure that I'm want to use in order to test my application. Just a procedure that will return a string based on a tinyInt that the user enters. That procedure looks like this:

DROP PROCEDURE IF EXISTS `getAccountTypeName`;
DELIMITER $$
CREATE PROCEDURE `getAccountTypeName`(DimAccountTypeID)
BEGIN

DECLARE DimAccountTypeID TinyINT DEFAULT 0

SELECT AccountTypeName
FROM Account_Type
WHERE AccountTypeID = DimAccountTypeID

END
$$

DELIMITER ;

Seems fine to me (being more experienced with MS SQL) but it returns the same error that my own local copy of MySQL Workbench did! Cannot load from mysql.proc. The table is probably corrupted

Everything I read about on the internet points to that being an issue where I need to upgrade MySQL.... I have no idea how I would upgrade seeing as I am just in a control panel here. Instead I feel like there must be some other issue, the tables that have data will still show data and I created them just yesterday, I don't see how any of this could be corrupted.

I tried looking at using

use mysql;
show create table mysql.proc;

as I've seen suggested, but that just returns another error of: #1044 - Access denied for user 'Birdy'@'%' to database 'mysql' (Birdy is my username). I don't know if THAT is the source of the problems, but I can run any other query sans the create procedure just fine.

Next thought from here is "hey if I can just get MySQL Workbench to connect and work then I can ignore the control panel". That isn't very fruitful either, here are my attempts at running some upgrade commands: http://i.imgur.com/yG1hKrQ.png (For that passsword, should I be using my Windows one? My MySQL Birdy username password? not sure which...)

The real question here anyway is pretty much just "help!". The source of the problem is "cannot create a MySQL query using phpMyAdmin" though and hopefully my little story here should help diagnose that. Would really appreciate some help with these issues :)

EDIT: I got mysql_upgrade to run but still, no dice. It doesn't fix the problems, still looks like this: http://i.imgur.com/NJpnRzw.png

EDIT 2: So I'm giving up on this for now, switching my DB over to MSSQL and sticking with what I know best. Reinstalling the db wasn't helpful and neither was the upgrade by my web hosts. Thanks for your help anyway guys

Connect to mysql server as root user, drop the table proc and create another one:

CREATE TABLE `proc` (
  `db` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `name` char(64) NOT NULL DEFAULT '',
  `type` enum('FUNCTION','PROCEDURE') NOT NULL,
  `specific_name` char(64) NOT NULL DEFAULT '',
  `language` enum('SQL') NOT NULL DEFAULT 'SQL',
  `sql_data_access` enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') NOT NULL DEFAULT 'CONTAINS_SQL',
  `is_deterministic` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `security_type` enum('INVOKER','DEFINER') NOT NULL DEFAULT 'DEFINER',
  `param_list` blob NOT NULL,
  `returns` longblob NOT NULL,
  `body` longblob NOT NULL,
  `definer` char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '',
  `comment` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `body_utf8` longblob,
  PRIMARY KEY (`db`,`name`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM