Error While importing Schema in sql - mysql

Hey guys im trying to import schema from mysql vesion 5.0 to 5.1. Every time i'm trying to import schema I got this error:
Error near Drop Proceduer service_tt_yes'
MySql.Data.MySqlClient.MySqlException: Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted.
I try to skip that procedure but error occur in next procedure.
Any solution!

You can probably use following command in MySQL Client
USE DATABASE_NAME; SOURCE [QUALIFIED-LOCATION]IMPORTED_SCHEMA.sql
Like if you have IMPORTED_SCHEMA.sql in D: drive then fire following command. Note there is no semi colon in the end
SOURCE D:\IMPORTED_SCHEMA.sql

Related

Issue with pulling information from mysql in flask

I am working on a simple program and attempting to pull some information out of a database. The table within the database that I am using is called names. If I do something like this:
self.cursor.execute("""select * from names WHERE first_name = 'Sarah' """)
for row in self.cursor.fetchall():
print(row[0])
I get exactly what I want. But if I change that name to a variable like and do something like:
name = input('Enter First name: ')
self.cursor.execute("""select * from names WHERE first_name=%s""", (name))
I get the following error: mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1
I know that there are other posts on this site close to my question and what I have tried from them does not seem to work. I have also tried following some tutorials and still get this error. So any help would be appreciated! Thank you! I am using mysql.connector, Python 3.4 and Flask.
Okay I found the answer myself. I had to do this: self.cursor.execute(query, (name,)) and the answer was found digging deeper and I found this site: Python MySQL Connector database query with %s fails

mysql DB Import script issue on version 5.6

I have a production server that hosts mysql 5.0 database. From there I exported the db backup script using export feature provided in phpmyadmin.
Now I want to restore database script on new server that 5.6 mysql. But when I run the import script I get following error:
Error Description:
unexpected character. (near at position mysql
On further investigation I found that the query was getting break at following location, please see image given below:
I noticed that this scring variable has 102129 Characters I also verified that I put '' in starting or in between then it does not break, but after n character it breaks & quite visible in phpmyadmin editor.
I am aware of using \' escape specifier, but this option is not useful in my case as this script is really long I manually can't replace such occurrances.
Please suggest any really healping solution.
Info:
While I was writing this post, I tried to execute the DB Script for single Record only (i.e., removing all other script) then i executed successfully. Therefore I can't identify the real reason for this issue.
Please suggest any db migration technique that I can use in this scenario.
Thanks
EDIT:
Following is the query that is being throwing exception on production phpmyadmin, but working elsewhere:
INSERT INTO `wp_options` (`option_id`, `option_name`, `option_value`, `autoload`, `blog_id`) VALUES
(297, 'wpcs_options', 'a:40:{s:5:"width";s:3:"973";s:6:"height";s:3:"399";s:12:"border_width";s:1:"0";s:12:"border_color";s:7:"#ffffff";s:11:"font_family";s:39:"\\''Trebuchet MS\\'', Helvetica, sans-serif";s:9:"font_size";s:2:"12";s:5:"color";s:7:"#000000";s:12:"heading_font";s:2:"18";s:13:"heading_color";s:7:"#ffffff";s:16:"background_color";s:7:"#ffffff";s:6:"update";s:7:"UPDATED";s:16:"square_per_width";s:1:"7";s:17:"square_per_height";s:1:"5";s:5:"delay";s:4:"3000";s:6:"sDelay";s:2:"30";s:7:"opacity";s:3:"0.7";s:10:"titleSpeed";s:3:"500";s:6:"effect";s:6:"random";s:10:"hoverPause";s:4:"true";s:24:"navigation_next_previous";s:4:"true";s:18:"navigation_buttons";s:4:"true";s:16:"navigation_color";s:7:"#000000";s:12:"show_excerpt";s:5:"false";s:11:"char_length";s:3:"200";s:10:"new_window";s:5:"false";s:5:"order";s:5:"false";s:12:"custom_image";s:4:"true";s:13:"post_category";s:1:"0";s:15:"number_of_posts";s:1:"4";s:19:"no_of_custom_images";s:1:"5";s:12:"slide_image1";s:92:"http://mydemozone.com/signaturewellnessv2/wp-content/plugins/content-slide/images/image1.jpg";s:16:"slide_imagelink1";s:60:"http://www.snilesh.com/resources/jquery/jquery-image-slider/";s:12:"slide_image2";s:92:"http://mydemozone.com/signaturewellnessv2/wp-content/plugins/content-slide/images/image2.jpg";s:16:"slide_imagelink2";s:132:"http://www.snilesh.com/resources/wordpress/wordpress-tips-and-tricks/wordpress-show-title-and-excerpt-of-child-pages-on-parent-page/";s:12:"slide_image3";s:92:"http://mydemozone.com/signaturewellnessv2/wp-content/plugins/content-slide/images/image3.jpg";s:16:"slide_imagelink3";s:90:"http://www.snilesh.com/resources/wordpress/wordpress-plugins/wordpress-news-ticker-plugin/";s:12:"slide_image4";s:92:"http://mydemozone.com/signaturewellnessv2/wp-content/plugins/content-slide/images/image4.jpg";s:16:"slide_imagelink4";s:66:"http://www.snilesh.com/resources/jquery/jquery-image-sliders-2010/";s:12:"slide_image5";s:92:"http://mydemozone.com/signaturewellnessv2/wp-content/plugins/content-slide/images/image5.jpg";s:16:"slide_imagelink5";s:65:"http://www.snilesh.com/resources/jquery/jquery-dynamic-selectbox/";}', 'yes', 0);
The above query returns following error:
Error
Static analysis:
1 errors were found during analysis.
Ending quote ' was expected. (near "" at position 349)
SQL query:
INSERT INTO `wp_options` (`option_id`, `option_name`, `option_value`, `autoload`, `blog_id`) VALUES (297, 'wpcs_options', 'a:40:{s:5:"width";s:3:"973";s:6:"height";s:3:"399";s:12:"border_width";s:1:"0";s:12:"border_color";s:7:"#ffffff";s:11:"font_family";s:39:"\\''Trebuchet MS\\'', Helvetica, sans-serif";s:9:"font_size";s:2:"12";s:5:"color";s:7:"
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''a:40:{s:5:"width";s:3:"973";s:6:"height";s:3:"399";s:12:"border_width";s:1:"0";' at line 2

Syntax error when trying to create a database with name: 9e1617bafr1_1

yesterday I stumbled upon a weird problem.
I have a PHP script that creates mysql databases for me based of some input.
When the script tried to generate a database with the name "9e1617bafr1_1" (without quotes) and I got this error "MySQL Error 1064: You have an error in your SQL syntax".
Query is CREATE DATABASE IF NOT EXISTS 9e1617bafr1_1
I also get the error when trying to execute it on https://de.piliapp.com/mysql-syntax-check/ and http://sqlfiddle.com/
I resolved it by using backticks before and after the database name but I'm still wondering why I got this error in the first place as the creation of "9d1617bafr1_1", "9f1617bafr1_1" and so on worked flawlessly.
Unfortunately I did not find anything useful on this behavior on the internet and as I'm very curious about it I wanted to ask if anybody know if this is a reserved word or if it violates the SQL standard in any way?
9e1617bafr1_1 is parsed as number (9e1617) followed by a character string (bafr1_1). Your other attempts, "9d1617bafr1_1", and "9f1617bafr1_1", don't start with scientific notation, so they don't get parsed that way.

Error in mysql database in Qt

I wrote this sql codes in qt5 in ubuntu. I want to update a table. But I received following error:
QSqlError(1065, "QMYSQL: Unable to execute query", "Query was empty")
This is my sql code:
query4.prepare("update food_main set cost=:material_cost,"+material+"=:material_num where name='"+material_name+"'");
query4.bindValue(":material_cost",material_cost);
query4.bindValue(":material_num",material__num);
query4.exec();
I must say that my table updates every time I run my code but I have the error too. Table and columns and variables were made in right method. What should I do?

Cannot use a MySQL UDF function

I have loaded an UDF function into MySQL (without having selected any particular DB). It used to work well during my session but now I get the error "ERROR 1305 (42000): FUNCTION currentdatabase.myfunction does not exist" when I try to use the function with the following sql statement :
select myfunction('aaa');
I then tried to drop the function and I got the same error code :
mysql> drop function myfunction;
ERROR 1305 (42000): FUNCTION database.myfunction does not exist
if a DB is selected.
Another error code otherwise :
ERROR 1046 (3D000): No database selected
So I decided to specify again the function and I got the following error code :
CREATE FUNCTION myfunction RETURNS INT SONAME 'myfunction.so';
ERROR 1125 (HY000): Function 'myfunction' already exists
My question is: how to use again my function ?
Thanks in advance.
Note: there is no space problem like ("select myfunction ('aaa');") as reported on several other websites.
I recently encountered this issue my self and I put together a quick blog post about it:
When installing a UDF recently I got an
annoying error message, which didn't seem to want to go away. Deleting
the function before attempting to remove it did not work so I used the
following set of escalating commands to attempt to get it to
install. But back to the error for a moment:
bash > mysql -u user -p < installdb.sql
Enter password:
ERROR 1125 (HY000) at line 7: Function 'lib_mysqludf_ssdeep_info' already exists This can be
solved really simply with the following options:
Attempt
to delete the function and then reinstall it Delete the
function row from the mysql.func table and then reinstall it
Stop the MySQL server (after trying option 2), start it again and
then reinstall it
From my testing you do not need to have backups of your binary database files as #jmcejuela suggests in his answer.
Source: http://simonholywell.com/post/2012/01/mysql-udf-install-error-function-already-exists.html
I believe the problem comes from removing the .so library before dropping the function/s. The server still believes it has the functions since they appear in SELECT * FROM mysql.func but of course calling these functions fail. Somehow DROP doesn't simply remove entries in this table but also checks whether the libraries are found which makes this fail. CREATE supposedly just check first the func table which makes this fail...
The solution is to restore the func table (func.MYI, func.MYD, func.frm files under your mysql's data/mysql) to the point everything matches.
Luckily I had a backup of these files. Otherwise you will have to backup them from a new mysql installation (you could simply install locally a new server not to remove your current one)
Bottom line: do not remove the .so libraries before dropping the functions.
Got some of these errors when swapping out (not dropping) the .so library before dropping the function(s).
Restarting the server eliminated the error messages, whether the functions were successfully dropped or not. Mysqld just looked at the mysql.func table and loaded functions from the (new) .so. I know restarting the server is not always an option, but if it is, it's fast and complete.