mysql select count(*) results in Data too long for column - mysql

I am running a count(*) on a view, but I get the following error. The view has several joins and views. But this error should only apply when changing a value on a table field, right?
mysql> select count(*) from dm.vSscore24 ;
ERROR 1406 (22001): Data too long for column 'pbs' at row 1
mysql>
db info
mysql> show variables like '%version%';
+-------------------------+-----------------------------+
| Variable_name | Value |
+-------------------------+-----------------------------+
| innodb_version | 5.7.20 |
| protocol_version | 10 |
| slave_type_conversions | |
| tls_version | TLSv1,TLSv1.1 |
| version | 5.7.20-0ubuntu0.16.04.1-log |
| version_comment | (Ubuntu) |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+-----------------------------+
thank you.

found the issue.
It was a function called inside a view that had a variable (named pbshape) too small for the maximum size of the column.
Luckily there were no columns named 'pbs' anywhere (in tables or views), and that made me wonder.
If the variable were named like bs I think I would never have found the answer :P
The word column in the error message 'Data too long for column' is extremely missleading.
thank you guys

Related

PHPMyAdmin | Event Scheduler cannot enabled and get #1577 error

I've stuck on this problem for a while.
I need to schedule a job for my query daily so I have to set global event_scheduler = ON
and I got this message ..
1577 - Cannot proceed because system tables used by Event Scheduler were found damaged at server start
some guys told me i have to restart db and do it again but it's not work.
I was going to my.cnf and type event_scheduler = ON in [mysqld] section and restart again
and it's still DISABLED.
someone told me it's a bug of version 5.5 but i'm using 5.6 .....
MariaDB [(none)]> SHOW VARIABLES LIKE "%version%";
+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| innodb_version | 5.6.22-72.0 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 10.0.17-MariaDB |
| version_comment | Source distribution |
| version_compile_machine | i386 |
| version_compile_os | osx10.6 |
| version_malloc_library | system |
+-------------------------+---------------------+
so I have no any idea what should i do with this thing :(
I also can't access the EVENT table in information_schema db with the same error.
if anyone can solve my problem. i'll owe you guys my entire life.
** i sincerely apologise if it's a stupid question **
Ps. I use XAMPP.
It is generally a good idea to research error codes and messages:
https://serverfault.com/questions/385015/mysql-damaged-system-tables
https://serverfault.com/questions/562282/mysqldump-error-1557-corrupt-event-table
https://serverfault.com/questions/100685/cannot-proceed-because-system-tables-used-by-event-scheduler-were-found-damaged
https://bugs.mysql.com/bug.php?id=70975

MySQL arithmetic calculation result differs between Windows and Linux

I have run this sql in windows & Linux version of mysql, and get the different result:
select (((((237803.3300+1659482.4400)/2.00)/1182208.5700)*30.00*6)+
(0.50*`(((((((1159248.2000+687984.6000)/2.00)/1527268.4000)*30.00*6)+
((((457300.0000+1707654.0300)/2.00)/1182208.5700)*30.00*6))
-(((((360.00*((1527268.4000-1182208.5700)-((2587.0000-((5354427.3100*0.0400*6)/12.00))
+99354.4800+10550.5600)))/((((((1159248.2000+687984.6000)/2.00)/1527268.4000)*30.00*6)+
((((457300.0000+1707654.0300)/2.00)/1182208.5700)*30.00*6))*0.5))-(0.50*((2587.0000-
((5354427.3100*0.0400*6)/12.00))+99354.4800+10550.5600)))*
(((((1159248.2000+687984.6000)/2.00)/1527268.4000)*30.00*6)+
((((457300.0000+1707654.0300)/2.00)/1182208.5700)*30.00*6)))/1182208.5700))-
((((237803.3300+1659482.4400)/2.00)/1182208.5700)*30.00*6)))) AS YF`
Windows version of mysql result: 105.93639914104807268662689486
Linux version of mysql result: 144.43789669025999363208811782
And I've been check this expression in some of other platform like java, excel, get the approximately value about: 105.93....., so I thought about that the calculation on linux mysql is incorrect or some of mysql variable set incorrect? Can anybody tell me why?
my linux version of mysql (At cloud server):
mysql>SHOW VARIABLES LIKE "%version%"
+-------------------------+---------------------------------+
| Variable_name | Value |
+-------------------------+---------------------------------+
| innodb_version | 1.1.8-20.1 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.18.1-Alibaba-rds-201406-log |
| version_comment | Source distribution |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+---------------------------------+
I did not look closely, but you are not selecting FROM anywhere
try this:
select (((((237803.3300+1659482.4400)/2.00)/1182208.5700)*30.00*6)+(0.50*(((((((1159248.2000+687984.6000)/2.00)/1527268.4000)*30.00*6)+((((457300.0000+1707654.0300)/2.00)/1182208.5700)*30.00*6))-(((((360.00*((1527268.4000-1182208.5700)-((2587.0000-((5354427.3100*0.0400*6)/12.00))+99354.4800+10550.5600)))/((((((1159248.2000+687984.6000)/2.00)/1527268.4000)*30.00*6)+((((457300.0000+1707654.0300)/2.00)/1182208.5700)*30.00*6))*0.5))-(0.50*((2587.0000-((5354427.3100*0.0400*6)/12.00))+99354.4800+10550.5600)))*(((((1159248.2000+687984.6000)/2.00)/1527268.4000)*30.00*6)+((((457300.0000+1707654.0300)/2.00)/1182208.5700)*30.00*6)))/1182208.5700))-((((237803.3300+1659482.4400)/2.00)/1182208.5700)*30.00*6)))) AS YF
FROM DUAL
Answer: 105.936399141048
Fiddle: http://sqlfiddle.com/#!2/a2581/32503/0

MySQL Queries taking too long to load

I have a database table, with 300,000 rows and 113.7 MB in size. I have my database running on Ubuntu 13.10 with 8 Cores and 8GB of RAM. As things are now, the MySQL server uses up an average of 750% CPU. and 6.5 %MEM (results obtained by running top in the CLI). Also to note, it runs on the same server as Apache2 Web Server.
Here's what I get on the Mem line:
Mem: 8141292k total, 6938244k used, 1203048k free, 211396k buffers
When I run: show processlist; I get something like this in return:
2098812 | admin | localhost | phpb | Query | 12 | Sending data | SELECT * FROM items WHERE thumb = 'Halloween 2013 Horns/thumbs/Halloween 2013 Horns (Original).png'
2098813 | admin | localhost | phpb | Query | 12 | Sending data | SELECT * FROM items WHERE thumb = 'Halloween 2013 Witch Hat/thumbs/Halloween 2013 Witch Hat (Origina
2098814 | admin | localhost | phpb | Query | 12 | Sending data | SELECT * FROM items WHERE thumb = 'Halloween 2013 Blouse/thumbs/Halloween 2013 Blouse (Original).png
2098818 | admin | localhost | phpb | Query | 11 | Sending data | SELECT * FROM items WHERE parent = 210162 OR auto = 210162
Some queries are taking an excess of 10 seconds to execute, this is not the top of the list, but somewhere in the middle just to give kind of a perspective of how many queries are stacking up in this list. I feel that it may have something to do with my Query Cash configurations. Here are the configurations show from running the SHOW STATUS LIKE 'Qc%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| Qcache_free_blocks | 434 |
| Qcache_free_memory | 2037880 |
| Qcache_hits | 62580686 |
| Qcache_inserts | 10865474 |
| Qcache_lowmem_prunes | 4157011 |
| Qcache_not_cached | 3140518 |
| Qcache_queries_in_cache | 1260 |
| Qcache_total_blocks | 4440 |
+-------------------------+----------+
I noticed that the Qcache_lowmem_prunes seem a bit high, is this normal?
I've been searching around StackOverflow, but I couldn't find anything that would solve my problem. Any help with this would be greatly appreciated, thank you!
This is probably one for http://dba.stackexchange.com. That said...
Why are your queries running slow? Do they return a large result set, or are they just really complex?
Have you tried running one of these queries using EXPLAIN SELECT column FROM ...?
Are you using indexes correctly?
How have you configured MySQL in your my.cnf file?
What table types are you using?
Are you getting any errors?
Edit: Okay, looking at your query examples. What data type is items.thumb? Varchar, Text? Is it not at all possible to query this table using another method than literal text matching? (e.g. ID number). Does this column have an index?

mysql show processlist query shows state = null

I have a script running a batch of very similar queries.
All of them, except one, run without any problem.
Only one query is getting stuck.
In "show processlist" the query has state=null
According to docs, show processlist should report "State=null" only for the "show processlist" thread itself.
Server version: 5.0.67 MySQL Community Server (GPL)
mysql> show processlist;
+---------+--------+-----------+--------------+---------+------+-------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+---------+--------+-----------+--------------+---------+------+-------+------------------------------------------------------------------------------------------------------+
| 3866613 | user | localhost | db_name | Query | 1986 | NULL | select log_time,log_action,log_action_id,log_object_id, #abcde:=if(log_action='abcde',to_ |
| 3873414 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+---------+--------+-----------+--------------+---------+------+-------+------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
Could be a bug of your version of mysql, take a look at this bug for more information .

MySQL: lower does not exist

I am trying to run a query like this:
SELECT lower (A.label) FROM addresses A;
and what I get in return is
ERROR 1305 (42000): FUNCTION db.lower does not exist
I am using
+-------------------------+-------------------------------+
| Variable_name | Value |
+-------------------------+-------------------------------+
| protocol_version | 10 |
| version | 5.0.92-community |
| version_comment | MySQL Community Edition (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | unknown-linux-gnu |
+-------------------------+-------------------------------+
Never had this issue before on any other system but this one... I was under the impression that lower is an internal function and is always there. What can be wrong?
Delete the space between lower and (
SELECT lower(A.label) FROM addresses A;
lower (A.label)
should be
lower(A.label)
MySQL doesn't like spaces between function name and argument: you are implying a column alias
(A.label) for a column lower otherwise
lower `(A.label)`
lower AS `(A.label)`