• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Home
  • Blog
  • Search

Kevin Dees

Full-Stack PHP Development

  • Twitter
  • Github
  • LinkedIn
You are here: Home / Archives for SQL

SQL

How to Reset the Primary Key Sequence ID in PostgreSQL

April 24, 2020 by Kevin Leave a Comment

brown wooden bench in field

I run into an issue today with PostgreSQL. I had manually entered a row into a table and it caused the primary key to fall out of sequence. To reset the primary key sequence ID on the PostgreSQL table I used the setval and pg_get_serial_sequence functions. Source: How to reset postgres’ primary key sequence when […]

Filed Under: Fix, SQL, Tips, Web

Fixing MySQL Error 1153 – Got a packet bigger than ‘max_allowed_packet’ bytes

February 19, 2020 by Kevin Leave a Comment

To fix, “MySQL Error 1153 – Got a packet bigger than ‘max_allowed_packet’ bytes” on Ubuntu edit your /etc/mysql/mysql.conf.d/mysqld.cnf. Once you have opened the file, increase the max_allowed_packet to a value that works for your environment. For example, in a local development environment, 100M can work. Then restart MySQL. Resources https://stackoverflow.com/questions/93128/mysql-error-1153-got-a-packet-bigger-than-max-allowed-packet-bytes

Filed Under: Fix, SQL, Web

How to Display and Debug All Database Queries Made by WordPress

October 3, 2019 by Kevin Leave a Comment

When working with WordPress you will eventually have the question, “How do I display all database queries made by WordPress?” In your wp-config.php file add the following: By setting SAVEQUERIES to true the wpdb global instance will store all the database queirs you make; this will allow you to inspect the number of queires each […]

Filed Under: Performance, SQL, Web, WordPress

Disable MySQL Strict Mode and NO_ZERO_DATE Errors in Laravel Homestead

December 18, 2018 by Kevin Leave a Comment

If you are using MySQL 8 or 5.7, on Laravel Forge, for example, use the command sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf. The options file /etc/mysql/conf.d/mysql.cnf is not the .cnf file we are using in this particular instance. Then add the sql_mode options you need and wrap them in quotes under the [mysqld] group. The sql_mode options needed […]

Filed Under: Fix, Laravel, Servers, SQL, Web

Import and Export MySQL and PostgreSQL

October 7, 2016 by Kevin Leave a Comment

There are many ways to export and import data from a database. You can use a Mac client like Sequal Pro for MySQL, for example. You can do the same for PostgreSQL, though I have not settled on a Mac client for PostgreSQL. Mac clients aside, you need can import and export your database SQL […]

Filed Under: Laravel, Servers, SQL, Web

Raw PHP and MySQL Eager Loading

September 21, 2016 by Kevin Leave a Comment

Working with complicated and joined data sets can be tricky for MySQL database performance. For example, What if you need to load multiple authors and their books from a database. How would you work around the N+1 problem and avoid unnecessary queries to the database without an expensive join statement? The answer is quite simple. […]

Filed Under: Performance, PHP, SQL, Web

  • Go to page 1
  • Go to page 2
  • Go to Next Page »

Footer

Get Dare To Code

Get the latest on full-stack PHP development in your inbox with a bi-weekly lesson from Kevin Dees.

Copyright © 2021 · Kevin Dees · Log in