How can I simulate an array variable in MySQL?

Well, I’ve been using temporary tables instead of array variables. Not the greatest solution, but it works. Note that you don’t need to formally define their fields, just create them using a SELECT: DROP TEMPORARY TABLE IF EXISTS my_temp_table; CREATE TEMPORARY TABLE my_temp_table SELECT first_name FROM people WHERE last_name=”Smith”; (See also Create temporary table from … Read more

MySQL – Make an existing Field Unique

ALTER IGNORE TABLE mytbl ADD UNIQUE (columnName); For MySQL 5.7.4 or later: ALTER TABLE mytbl ADD UNIQUE (columnName); As of MySQL 5.7.4, the IGNORE clause for ALTER TABLE is removed and its use produces an error. So, make sure to remove duplicate entries first as IGNORE keyword is no longer supported. Reference

MySQL ON DUPLICATE KEY – last insert id?

Check this page out: https://web.archive.org/web/20150329004325/https://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html At the bottom of the page they explain how you can make LAST_INSERT_ID meaningful for updates by passing an expression to that MySQL function. From the MySQL documentation example: If a table contains an AUTO_INCREMENT column and INSERT … UPDATE inserts a row, the LAST_INSERT_ID() function returns the AUTO_INCREMENT value. … Read more

Convert MySQL to SQlite [closed]

There is a mysql2sqlite.sh script on GitHub As described in the header, the script can be used like this: ./mysql2sqlite.sh myDbase | sqlite3 database.sqlite alternatives an updated version https://github.com/dumblob/mysql2sqlite A simpler script was posted at the the MySQL Forums

How can I initialize a MySQL database with schema in a Docker container?

I had this same issue where I wanted to initialize my MySQL Docker instance’s schema, but I ran into difficulty getting this working after doing some Googling and following others’ examples. Here’s how I solved it. 1) Dump your MySQL schema to a file. mysqldump -h <your_mysql_host> -u <user_name> -p –no-data <schema_name> > schema.sql 2) … Read more

Illegal mix of collations MySQL Error

SET collation_connection = ‘utf8_general_ci’; then for your databases ALTER DATABASE your_database_name CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; MySQL sneaks swedish in there sometimes for no sensible reason.

Remote Connections Mysql Ubuntu

To expose MySQL to anything other than localhost you will have to have the following line For mysql version 5.6 and below uncommented in /etc/mysql/my.cnf and assigned to your computers IP address and not loopback For mysql version 5.7 and above uncommented in /etc/mysql/mysql.conf.d/mysqld.cnf and assigned to your computers IP address and not loopback #Replace … Read more

Choosing a stand-alone full-text search server: Sphinx or SOLR? [closed]

I’ve been using Solr successfully for almost 2 years now, and have never used Sphinx, so I’m obviously biased. However, I’ll try to keep it objective by quoting the docs or other people. I’ll also take patches to my answer 🙂 Similarities: Both Solr and Sphinx satisfy all of your requirements. They’re fast and designed … Read more