Mysql

MySQL is a free, open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). DO NOT USE this tag for other DBs such as SQL Server, SQLite etc. These are different DBs which all use SQL to manage the data.

72 votes
14 answers
2.7K views
How do I see all foreign keys to a table or column?

In MySQL, how do I get a list of all foreign key constraints pointing to a particular table? a particular colu

avatar
Scot
0 1 0 9
asked 07 September, 2021
69 votes
11 answers
2.1K views
MySQL: Grant **all** privileges on database

I've created database, for example 'mydb'. CREATE DATABASE mydb CHARACTER SET utf8 COLLATE ut

avatar
Stacia
0 1 0 9
asked 07 September, 2021
60 votes
8 answers
2.9K views
Create new user in MySQL and give it full access to one database

I want to create a new user in MySQL and give it full access only to one database, say dbTest, that I create w

avatar
Emilia
0 1 0 9
asked 07 September, 2021
60 votes
24 answers
590 views
Find duplicate records in MySQL

I want to pull out duplicate records in a MySQL Database. This can be done with: SELECT address, count(id) a

avatar
Emilia
0 1 0 9
asked 07 September, 2021
60 votes
16 answers
2.1K views
MySQL Error 1093 - Can't specify target table for update in FROM clause

I have a table story_category in my database with corrupt entries. The next query returns the corrupt entries:

avatar
Wei
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
1.5K views
Disable ONLY_FULL_GROUP_BY

I accidentally enabled ONLY_FULL_GROUP_BY mode like this: SET sql_mode = 'ONLY_FULL_GROUP_BY'; Ho

avatar
Shanita
0 1 0 9
asked 07 September, 2021
60 votes
13 answers
2.5K views
How to truncate a foreign key constrained table?

Why doesn't a TRUNCATE on mygroup work? Even though I have ON DELETE CASCADE SET I get: ERROR 1701 (4

avatar
Hilario
0 1 0 9
asked 07 September, 2021
59 votes
27 answers
1.6K views
Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

This should be dead simple, but I cannot get it to work for the life of me. I'm just trying to connect re

avatar
Lawanda
0 1 0 9
asked 07 September, 2021
64 votes
14 answers
756 views
Duplicating a MySQL table, indices, and data

How do I copy or clone or duplicate the data, structure, and indices of a MySQL table to a new one? This is w

avatar
Kisha
0 1 0 9
asked 07 September, 2021
47 votes
26 answers
956 views
Finding duplicate values in MySQL

I have a table with a varchar column, and I would like to find all the records that have duplicate values in t

avatar
Forrest
0 1 0 9
asked 07 September, 2021
59 votes
4 answers
1.2K views
TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT maximum storage sizes

Per the MySQL docs, there are four TEXT types: TINYTEXT TEXT MEDIUMTEXT LONGTEXT What is the maximum length t

avatar
Venice
0 1 0 9
asked 07 September, 2021
47 votes
8 answers
1.3K views
MySQL: Large VARCHAR vs. TEXT?

I've got a messages table in MySQL which records messages between users. Apart from the typical ids and m

avatar
Rudolf
0 1 0 9
asked 07 September, 2021
57 votes
12 answers
679 views
"INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"

While executing an INSERT statement with many rows, I want to skip duplicate entries that would otherwise caus

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
58 votes
11 answers
1.8K views
How can I find all the tables in MySQL with specific column names in them?

I have 2-3 different column names that I want to look up in the entire database and list out all tables which

avatar
Yolando
0 1 0 9
asked 07 September, 2021
58 votes
26 answers
1.9K views
How do you set a default value for a MySQL Datetime column?

How do you set a default value for a MySQL Datetime column? In SQL Server it's getdate(). What is the eq

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
54 votes
14 answers
2.1K views
How do I specify unique constraint for multiple columns in MySQL?

I have a table: table votes ( id, user, email, address, primary key(id), ); Now I want

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
58 votes
20 answers
484 views
MySQL error code: 1175 during UPDATE in MySQL Workbench

I'm trying to update the column visited to give it the value 1. I use MySQL workbench, and I'm writi

avatar
Shanita
0 1 0 9
asked 07 September, 2021
51 votes
17 answers
684 views
How to get the sizes of the tables of a MySQL database?

I can run this query to get the sizes of all tables in a MySQL database: show table status from myDatabaseNam

avatar
Dusty
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
1.7K views
How do I quickly rename a MySQL database (change schema name)?

The MySQL manual at MySQL covers this. Usually I just dump the database and reimport it with a new name. This

avatar
Freida
0 1 0 9
asked 07 September, 2021
55 votes
8 answers
2.4K views
What's the difference between utf8_general_ci and utf8_unicode_ci?

Between utf8_general_ci and utf8_unicode_ci, are there any differences in terms of performance?

avatar
Adolfo
0 1 0 9
asked 07 September, 2021