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
80
votes
3 answers

sql error errno: 121

CREATE TABLE `users` ( `UID` INT UNSIGNED NOT NULL AUTO_INCREMENT , `username` VARCHAR(45) NOT NULL , `password` VARCHAR(100) NULL , `name` VARCHAR(100) NULL , `gender` BIT NULL , `email` VARCHAR(255) NULL , `phone` VARCHAR(30) NOT…
user396420
80
votes
3 answers

Retrieve last inserted id with Mysql

Good day, I am willing to retrieve the id value of a freshly inserted row in Mysql. I know there is mysqli_insert_id function, but: I can't specify the table Maybe there would be a risk of retrieving the wrong id, if a query is made in the…
lopata
  • 1,325
  • 1
  • 10
  • 23
80
votes
19 answers

Generate an integer sequence in MySQL

I need to do a join with a table/result-set/whatever that has the integers n to m inclusive. Is there a trivial way to get that without just building the table? (BTW what would that type of construct be called, a "Meta query"?) m-n is bounded to…
BCS
  • 75,627
  • 68
  • 187
  • 294
80
votes
5 answers

What's the differences between stored procedures, functions and routines?

In MySQL database context, what is the difference among these 3 terms: stored procedure stored function stored routine Also the build-in functions like those date time functions (e.g. WEEKDAY() etc) are considered as what?
Yang
  • 9,794
  • 15
  • 44
  • 52
80
votes
5 answers

MySql workbench query history ( last executed query / queries ) i.e. create / alter table, select, insert update queries

Want to see last executed queries in MySql Workbench whether its create / alter table query select / insert / update query or any query list. in short want to see history of all queries
murtaza.webdev
  • 3,523
  • 4
  • 22
  • 32
80
votes
3 answers

How to do select from where x is equal to multiple values?

I am debugging some code and have encountered the following SQL query (simplified version): SELECT ads.*, location.county FROM ads LEFT JOIN location ON location.county = ads.county_id WHERE ads.published = 1 AND ads.type = 13 AND ads.county_id =…
Binarytales
  • 9,468
  • 9
  • 32
  • 38
80
votes
11 answers

How to select rows where column value IS NOT NULL using CodeIgniter's ActiveRecord?

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to select the rows in a table where a field is not set to NULL: $this->db->where('archived !=', 'NULL'); $q = $this->db->get('projects'); That only returns this…
rebellion
  • 6,628
  • 11
  • 48
  • 79
80
votes
16 answers

Automate mysql_secure_installation with echo command via a shell script

I am trying to automate mysql_secure_installation script with automated response. My code is as follows : echo "& y y abc abc y y y y" | ./usr/bin/mysql_secure_installation The actual questions which i am automating are as follows: Enter current…
cucucool
  • 3,777
  • 8
  • 48
  • 63
80
votes
15 answers

MySQL Install: ERROR: Failed to build gem native extension

I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line. I run the command gem install mysql and I receive the following: Building native extensions. This could take a while...…
Kieran Senior
  • 17,960
  • 26
  • 94
  • 138
80
votes
9 answers

How to speed up SELECT .. LIKE queries in MySQL on multiple columns?

I have a MySQL table for which I do very frequent SELECT x, y, z FROM table WHERE x LIKE '%text%' OR y LIKE '%text%' OR z LIKE '%text%' queries. Would any kind of index help speed things up? There are a few million records in the table. If there is…
Tom
  • 6,991
  • 13
  • 60
  • 78
80
votes
4 answers

Are column and table name case sensitive in MySQL?

If I have a column names called category_id and Category_Id, are they different? And if I have table called category and Category, are they different?
shin
  • 31,901
  • 69
  • 184
  • 271
80
votes
6 answers

Re-assign host access permission to MySQL user

I have several thousand MySQL users all set to allow access from a specific host. The problem is that now I'm going to have two machines (more in the future) which will need to use the same account to access each of their databases. I'd like a quick…
Nick Jennings
  • 3,853
  • 6
  • 30
  • 45
80
votes
18 answers

mysqlworkbench giving version error on exporting database

When I try to export my database through MySQL Workbench remotely from localserver, I am getting some below version error: mysqldump Version Mismatch [Content] mysqldump.exe is version 5.5.16, but the MySQL Server to be dumped has version…
Sizzling Code
  • 5,932
  • 18
  • 81
  • 138
80
votes
4 answers

DateTime group by date and hour

I have a datetime called activity_dt and the data looks like this: 2/5/2013 9:24:00 AM 2/7/2013 7:17:00 AM How do i group by date and hour?
user1468667
80
votes
12 answers

How to change mysql to mysqli?

Based on this code below I use for regular mysql, how could I convert it to use mysqli? Is it as simple as changing mysql_query($sql); to mysqli_query($sql);?
JasonDavis
  • 48,204
  • 100
  • 318
  • 537