Questions tagged [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. Those are different DBs that all use their own dialects of SQL to manage the data. Always specify the exact version of the server in the question. Versions 5.x differ greatly in their capabilities from versions 8+.

MySQL is an Open Source RDBMS (Relational Database Management System) that runs as a server providing multi-user access to several databases. Its source code is available under the GNU GPL (General Public License). MySQL was acquired by Oracle in 2009.

MariaDB is a fork of MySQL using the same dialect of SQL and offering most of the same functions. See for fork-specific questions and answers.

MySQL offers standard database driver connectivity for using MySQL with applications and tools compatible with industry standards ODBC and JDBC.

How to ask a good and answerable question

Please see this post: Tips for asking a good Structured Query Language (SQL) question to get tips on how to ask a question about MySQL. Following some of these steps will help people to help you solve your problem.

Minimal, reproducible examples help the Stack Overflow community give good answers. Please read Why should I provide a Minimal Reproducible Example for a very simple SQL query?.

Always specify the exact version of the server in the question. Versions 5.x differ greatly in their capabilities from versions 8+.

Pronunciation

Officially it is /maɪˌɛskjuːˈɛl/ ("My S-Q-L"), but is often pronounced /maɪˈsiːkwəl/ ("My Sequel").

Latest Version (MySQL Community Server 8.0.27) and Version History

Example

SELECT * FROM users ORDER BY name

Resources

MySQL Tutorials

Popular questions

Popular administration tools

Chat Room

Related tags

661202 questions
79
votes
7 answers

Warning: mysqli_connect(): (HY000/2002): No such file or directory

I'm trying to install vanilla forums on my Mac, and for this I just created a database and a user from the MySQL command line: mysql> CREATE DATABASE vanilla; Query OK, 1 row affected (0.00 sec) mysql> create user 'vanilla_user3'@'localhost'…
kramer65
  • 50,427
  • 120
  • 308
  • 488
79
votes
32 answers

mysqldump Error 1045 Access denied despite correct passwords etc

This is a tricky one, I have the following output: mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect When attempting to export my database with mysqldump on Windows XP. The username…
79
votes
12 answers

MySQL vs. SQL Server vs. Oracle

I have always only used MySQL and no other database system. A question came up at a company meeting today and I was embarrassed I did not know: To a developer, what earth-shaking functionality do MS or Oracle offer that MySQL lacks and which allows…
KJ Saxena
  • 21,452
  • 24
  • 81
  • 109
79
votes
3 answers

Looping Over Result Sets in MySQL

I am trying to write a stored procedure in MySQL which will perform a somewhat simple select query, and then loop over the results in order to decide whether to perform additional queries, data transformations, or discard the data altogether. …
Dereleased
  • 9,939
  • 3
  • 35
  • 51
79
votes
1 answer

MySQL COUNT with LIMIT

What I want to do is SUM a column, but also COUNT the number of rows it is summing, with a limit of no more than 5 rows. So my query is: SELECT COUNT(*), SUM(score) FROM answers WHERE user=1 LIMIT 5 What I expected back was a COUNT(*) up to 5 (I…
Lee
  • 10,496
  • 4
  • 37
  • 45
79
votes
9 answers

Change output format for MySQL command line results to CSV

I want to get headerless CSV data from the output of a query to MySQL on the command line. I'm running this query on a different machine from the MySQL server, so all those Google answers with "INTO OUTFILE" are no good. So I run mysql -e "select…
spiffytech
  • 6,161
  • 7
  • 41
  • 57
79
votes
3 answers

MySQL delete multiple rows in one query conditions unique to each row

So I know in MySQL it's possible to insert multiple rows in one query like so: INSERT INTO table (col1,col2) VALUES (1,2),(3,4),(5,6) I would like to delete multiple rows in a similar way. I know it's possible to delete multiple rows based on the…
srchulo
  • 5,143
  • 4
  • 43
  • 72
79
votes
31 answers

Loading .sql files from within PHP

I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several .sql files. I had planned to open the file and…
Josh Smeaton
  • 47,939
  • 24
  • 129
  • 164
79
votes
4 answers

mysql update query with sub query

Can anyone see what is wrong with the below query? When I run it I get: #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 where a.CompetitionID =…
user1542043
  • 795
  • 1
  • 5
  • 4
78
votes
4 answers

MySQL: get MAX or GREATEST of several columns, but with NULL fields

I'm trying to select the max date in three different fields in each record (MySQL) So, in each row, I have date1, date2 and date3: date1 is always filled, date2 and date3 can be NULL or empty The GREATEST statement is simple and concise but has no…
Ivan
  • 2,463
  • 6
  • 39
  • 51
78
votes
7 answers

MySQL How do you INSERT INTO a table with a SELECT subquery returning multiple rows?

MySQL How do you INSERT INTO a table with a SELECT subquery returning multiple rows? INSERT INTO Results ( People, names, ) VALUES ( ( SELECT d.id FROM Names f JOIN People d ON d.id = f.id …
stackoverflow
  • 18,348
  • 50
  • 129
  • 196
78
votes
4 answers

sql query with multiple where statements

I am having a rather, for me, complicated mysql query on which I am totally stuck and cannot find any answer for online. Here's my query: SELECT items.* FROM items INNER JOIN items_meta_data WHERE ( (meta_key = 'lat' AND meta_value >= '55') …
user1117774
  • 801
  • 1
  • 6
  • 6
78
votes
14 answers

How to print exact sql query in zend framework ?

I have the following piece of code which i taken from model, ... $select = $this->_db->select() ->from($this->_name) ->where('shipping=?',$type) …
mymotherland
  • 7,968
  • 14
  • 65
  • 122
78
votes
3 answers

MySQL VARCHAR size?

If I have a VARCHAR of 200 characters and that I put a string of 100 characters, will it use 200 bytes or it will just use the actual size of the string?
SBSTP
  • 3,479
  • 6
  • 30
  • 41
78
votes
4 answers

SQL unique varchar case sensitivity question

I'm trying to populate a SQL table with a list of words. The table itself it pretty simple: CREATE TABLE WORDS( ID BIGINT AUTO_INCREMENT, WORD VARCHAR(128) NOT NULL UNIQUE, PRIMARY KEY(ID) ); The problem I'm running into is this: when I do…
Seth
  • 5,596
  • 8
  • 42
  • 56
1 2 3
99
100