All versions of MySQL (not Microsoft SQL Server). Please also add a version-specific tag like mysql-5.7 if that is relevant to the question.

learn more… | top users | synonyms

2
votes
2answers
5k views

The best MySQL configuration for my server

I'm little newbie in configuring mysql and I need some advices. Few days ago I made little home server on Ubuntu Server 12.04 with samba, mysql 5.5, apache 2.2, PHP 5.4.6 etc. I'm using it to ...
6
votes
2answers
2k views

Fetch the newest row grouped by a column in MySQL

My problem seems like it should have a much simpler solution than what I have come up with. Starting with this data set: log_table +--------+-----------+------------------+---------+ | log_id | ...
2
votes
1answer
874 views

Populating an empty table using loops, conditionals, and accessing multiple tables

This question pertains to a MySQL database, although, in the end, this may be database neutral. I am trying to populate an empty table (let's call it NewTable) that I created. The data population is ...
2
votes
2answers
3k views

MySQL order by - one column conditional on another column

In MySQL I have a table (simplified for this question) CREATE TABLE `projects` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `priority` int(11) DEFAULT '1000000', ...
2
votes
2answers
444 views

Does MySQL have information_schema.VIEW_COLUMN_USAGE or an equivalent?

SQL Server has a an information_schema view, 'VIEW_COLUMN_USAGE', which you can use to determine the actual/base tables that the columns in a view reside in. I'm looking for the equivalent in MySQL - ...
2
votes
1answer
1k views

Restoring MySQL database with db dump and binlogs

I have a database running on our production web server that I have set up as a master with a single slave in another datacenter. When reading through the MySQL replication setup instructions, they ...
1
vote
1answer
281 views

MySql - selecting into file and re-loading it with special characters

I have a MySql table called twitter_statuses which as the title suggests holds twitter statuses. here is the table structure. this table contains all sort of characters in the text column, and some ...
1
vote
1answer
638 views

Optimizing User Defined Custom Columns

I am building a web based app that has the potential to have very high traffic and collect a lot of data. Most of this traffic will be utilizing the database. Database is MySQL InnoDB. I want to give ...
1
vote
2answers
1k views

How can Stored Procedures and Triggers be Automatically Loaded When MySQL Starts

Is there any straightforward method of doing as the questions asks? We are using MySQL 5.5 & Linux.
2
votes
1answer
748 views

MySQL Unique Index Keylength

I am hashing keys from one table that provides a 256 bit (64 char length) alphanumeric string that I intend to use in a second table as a foreign key. The engine of choice here is InnoDB. There are ...
0
votes
1answer
70 views

Mysql restore all data from Master

MySQl Slave replication server got crashed and I am missing around 60 tables, some table structure and data which present in master and by DB size is more than 25Gb, How I Can restore to resolve ...
0
votes
1answer
407 views

how to pass url value to index [closed]

How to read the value from URL and compare with index that i have created in MYSQL table. I have a form where provide list of selection using drop down list and i pass the selected value to the next ...
1
vote
2answers
253 views

MySQL Cluster Steps To Recover Data If Catstrophic Failure Occurs

I want to know if a catstrophic failure occurs (like a power outage), and all nodes in MySQL Cluster are shutdown in cluster then data will be lost even though a backup was taken? Or it possible that ...
3
votes
2answers
4k views

How much memory do I need for innodb buffer pool?

I read here that You need buffer pool a bit (say 10%) larger than your data (total size of Innodb TableSpaces) On the other hand I've read elswher that innodb_buffer_pool_size must be up to ...
66
votes
4answers
118k views

How large should be mysql innodb_buffer_pool_size?

I have a busy database with solely InnoDB tables which is about 5GB in size. The database runs on a Debian server using SSD disks and I've set max connections = 800 which sometimes saturate and grind ...
0
votes
1answer
2k views

Partitioning not working need primary key?

We are trying some partitioning as below. ALTER TABLE tblreceipt PARTITION BY RANGE (MONTH(receiptDate)) ( PARTITION p1 VALUES LESS THAN (TO_DAYS('2012-10-20')), PARTITION p2 VALUES LESS THAN ...
-3
votes
1answer
145 views

percona innobackup failed

I'm trying to get percona innobackup but I'm struggling with this since 4hrs. Tried all possible ways from many forums. interms of changing my.cnf, parsing arguments but still not able to get this ...
1
vote
2answers
293 views

SQL query based on foreign key relationship

I have two tables, a Project and an Action: Project has the following fields: project_name Action has the following fields: action_name project status There is a one-to-many relationship ...
1
vote
0answers
67 views

Partition guides and possible solutions?

We have a table called tblLink which is the main table and have its primary key in many other tables as shown below. The issue now we want to keep only the latest 3 months data and the rest should be ...
2
votes
0answers
571 views

MySQL database structure: more columns or more rows [closed]

I collect how people tag topics with categories in table like: ID | topic_id | votes_Category_1 | votes_Category_2 |.......... | votes_Category_12 This table holds 1 row per topic and dynamically ...
3
votes
2answers
2k views

Blocking drop database command

I created a MySQL database and created a new user dedicated to that database with all permissions. The new user then proceeded of dropping the database in addition to all tables. I need to block that ...
0
votes
1answer
395 views

Most efficient way to structure segmented data

I am faced with a set of data which I am currently unsure on how to store efficiently. The data in question relates to a calendar which stores information on two different categories of event which ...
0
votes
1answer
1k views

“Connection to host lost” using telnet to MySQL

I am trying to setup MySQL Workbench to manage a remote database and I keep getting "waiting for initial communication packet" error. So I try to telnet to the box on port 3306, I get in, but then I ...
3
votes
1answer
620 views

adding another table to existing MySQL replication scenario

I'm running a simple MySQL replication scenario MASTER ➙ BLACKHOLE ➙ SLAVE, replicating only a number of tables via replicate-do-table on BLACKHOLE and SLAVE. Now I would like to add several more ...
4
votes
1answer
339 views

MySQL table design of logging tables

I'm not a DBA by any means, but I have a basic understanding of some of the underlying principles of database optomization. Currently we have a table that logs session data, it writes about ...
4
votes
1answer
25k views

MySQL: Execute CREATE TEMPORARY TABLE SELECT just one time?

I want to create a temporary table with some select-data. My (strange) problem is that I have to do the same query more than one time. CREATE TEMPORARY TABLE IF NOT EXISTS cache (id int(11) NOT ...
1
vote
1answer
1k views

`show procedure status` doesn't list all of the procedures?

mysql-server-5.5.28-1.el5.remi I'm pulling my hair with this problem: only EMS SQL Manager can list all of my store procedures (1763). mysql client, mysql-workbench, Navicat, ... only see some of ...
1
vote
1answer
145 views

Slow-running query on a new VM

The below query is taking a lot of time, more than an hour. Is there anything I could to to tune it, server-wise or query-wise? Its just 23000 records. EXPLAIN SELECT bc.charge , ...
6
votes
1answer
4k views

Disable console output when executing a SQL file using MySQL source command

I begin by launching the MySQL command line tool: mysql --user=myusername --password=mypassword --silent --force -b The last -b option is used to disable beep on error. Then I choose a database: ...
5
votes
3answers
3k views

How to change data structure in mysql using mysqldump without deleting files

Essentially what I'm trying to do is sync a production server with a sandbox server, but only the table structures and stored procedures. The procedures aren't any problem since they can be overriden, ...
1
vote
1answer
1k views

calculate the difference between two column aliases in a SELECT statement?

I'm not sure how to do the last part of my query, which is doing calculations directly with the aliases: (SUM(task_avg - minutes) AS difference. I don't think I can do it as easy as I'd like, but ...
3
votes
1answer
3k views

MySQL: Unique constraint on large column

I am trying to create an InnoDB table that contains a VARCHAR column that can hold up to 3071 characters. I would like to enforce a UNIQUE constraint on the data of this column. MySQL appears to ...
0
votes
1answer
177 views

Handling error of foreign key

How to set a FK value NULL upon receiving error for foreign key constraint? Consider a simple table a CREATE TABLE test ( id int(11) NOT NULL AUTO_INCREMENT ex_key int(11), FOREIGN ...
15
votes
5answers
21k views

Alter table on live production databases

How do most "popular" (MySQL, Postgres...) database system handle altering tables on live production databases (like adding, deleting or changing the type of colums)? I know the correct way is to ...
1
vote
0answers
136 views

MySQL: Fixing Unique key constraint violation

I have a database with an unique key constraint. When I import this database from a dump created by mysqldump I get '14698-3' for key 'UNQ_CATALOGS EARCH_FULLTEXT_PRODUCT_ID_STORE_ID' But when I ...
0
votes
1answer
101 views

SQL Query for the following structure

Given the following type of data structure. ID NAME TREELEFT TREERIGHT PARENT 1 XYZ 1 2 0 2 ABC 3 6 0 3 DEF 4 5 ...
2
votes
1answer
182 views

Combining columns in index

With reference to RolandoMySQLDBA's answer on MySQL: Index when joining to tables not being used (Performance optimizing question) He mentioned Make sure you build an index that involves the ...
2
votes
3answers
2k views

MySQL ignoring some params from my.cnf

I have a virtual box with 2 installed instances of MySQL. First instance: - /etc/mysql/my.cnf - /var/lib/mysql - port = 3306 Second instance: - /etc/mysql2/my.cnf - /var/lib/mysql2 - port = 3307 ...
1
vote
1answer
366 views

GROUP_CONCAT with ORDER BY , but results are not ordered

The following query works fine SELECT *, (SELECT GROUP_CONCAT(url SEPARATOR '$$' ) FROM project_photos WHERE project_id = projects.id ORDER BY priority) AS images FROM projects WHERE catID = 2 LIMIT ...
1
vote
1answer
410 views

Setting up DRBD on an active MySQL server

When it comes to setting up DRBD and MySQL, is the following possible? Set up DRBD on an active MySQL server Set up DRBD with no downtime allowed
3
votes
3answers
3k views

MySQL optimization - year column grouping - using temporary table, filesort

I have a transactions table which is having 600,000 records, I need to list the count for the dashboard on financial year basis. The table used is MyISAM. I tried adding index for the transaction date ...
4
votes
1answer
10k views

What exactly are iblog files in mysql

I would like to understand these ibdata files as these play vital role in the crash recovery procedure. I could not find proper resources over the web for this.
0
votes
1answer
388 views

How to avoid certain characters in MySQL full text search?

I have a column named parcel_number of varchar type. It contains values like ab-cd-ef and uvwxyz. A search for abcdef or uv-wx-yz does not return those records. How should I write the query to meet ...
1
vote
1answer
982 views

Slow insert with MySQL full-text index

I use a full-text index in a MySQL table, and each insert into this table takes about 3 seconds. It seems that MySQL rebuilds (a part) of the full text index after each insert/update. Is this right? ...
1
vote
0answers
887 views

multiple child records in a single row by join

I have one master table (teacher) structured like teacherId Name Class 1 Praveen 10 2 John 9 and having a child table (student) structured like studentId ...
3
votes
1answer
609 views

Model with variable number of “properties” of different types.

I would like to have a table of microscope slides, where on top of the basic id, name,date_created would each slide also have a number of editable "properties". Imagine one slide having ...
3
votes
0answers
131 views

Once in a while synchronization of the independently updated mysql databases problem

I have a production database and a test database running on MySQL with MyISAM and InnoDB tables, which are updated independently. The Production database is updated by system and sometimes by a user. ...
1
vote
1answer
124 views

Selecting the popular posts using three tables

I have three tables: posts - contains the posts by users, post_reviews - contains the likes on the posts, and post_share - contains the post id and user id of that which is shared. I would like to ...
0
votes
2answers
1k views

how to estimate rebuild index on 140 million records?

My existing project has data of about 140million records in Contentq table. And I have planned to rotate the table just incase not to face any load on the table. So I have planned to rotate data older ...
1
vote
2answers
789 views

SHOW FULL PROCESSLIST for some host does not show `Client port`

I am executing Show Full Processlist; and output does not show client port for some hosts in Host column Documentation says that each and every connection has host:client_port format. My question is ...