Tag Archives: mysql

Fixing wp_termmeta doesn’t exist error

One day, I open my email via mail command and see bunch of error mail received by me, written something like this:

PHP message: WordPress database error Table 'blog.wp_termmeta' doesn't exist for query SELECT term_id, meta_key, meta_value FROM wp_termmeta WHERE term_id IN (108) ORDER BY meta_id ASC made by require('wp-blog-header.php'), wp, WP->main, do_action_ref_array, call_user_func_array, Jetpack_RelatedPosts->action_frontend_init, Jetpack_RelatedPosts->_action_frontend_init_ajax, Jetpack_RelatedPosts->get_for_post_id, Jetpack_RelatedPosts->_get_related_posts, Jetpack_RelatedPosts->_get_related_post_data_for_post, Jetpack_RelatedPosts->_generate_related_post_context, get_the_category, get_the_terms, wp_get_object_terms, update_termmeta_cache, update_meta_cache

Upon diving in Google ocean, I found this solution that may solve the problem:

CREATE TABLE `wp_termmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `term_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`meta_id`),
  KEY `term_id` (`term_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB AUTO_INCREMENT=3255 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Use this SQL query to manually add the wp_termmeta table into your WordPress database; if the wp_termmeta table doesn’t exist in your DB.


Update MySQL root password

To change your MySQL root password, first you need to connect to the sql server via terminal
mysql -u root -p

In my case, my root password is null/empty. So I need to create new mysql root password.
So, after you login to the mysql, enter this command:

use mysql;
update user set password=PASSWORD("") where User='root';
flush privileges;

Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS

First, you need to get MySQL installers from https://dev.mysql.com/downloads/mysql/#downloads

I ran following command to get MySQL 5.6.14(32bit):
wget -O mysql-5.6.14.deb https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-i686.deb/from/http://cdn.mysql.com/

Install dependency
sudo apt-get install libaio1

Then install Mysql 5.6.14
sudo dpkg -i mysql-5.6.14.deb

Backup your MySQL 5.5 data
You will need this only if you are upgrading…

cd ~
mkdir backup && cd backup
mysqldump -A –events > dump/alldb.sql

cp -pr /etc/mysql config

service mysql stop
cp -pr /var/lib/mysql/ data

This is your backup folder & data in case if of anything. But if everything when well, you will not need the backups.

Remove MySQL 5.5 Packages
sudo apt-get remove mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5
sudo apt-get autoremove

Setup MySQL 5.6 Startup Script
cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server
update-rc.d -f mysql remove
update-rc.d mysql.server defaults

Update environment
sudo nano /etc/environment
source /etc/environment

Confirm changes
Run this command:
which mysql

Should show:

Update mysql config file
sudo nano /etc/mysql/my.cnf
basedir = /opt/mysql/server-5.6
lc-messages-dir = /opt/mysql/server-5.6/share

Start MySQL 5.6
Its time to start new mysql…
service mysql.server start

If you cannot start mysql server, then install this package:
sudo apt-get install ia32-libs php5-mysql

Then try to start it again.

Final Step
If you are upgrading from mysql, run this command:
mysql_upgrade -u root -p

Otherwise if its a fresh install, run following:
/opt/mysql/server-5.6/scripts/mysql_install_db –user=mysql –datadir=/var/lib/mysql

Enjoy. 🙂

Check MySQL db size

If you want to find how much your database size in MySQL, you can run this command in mysql console:

If you want the output in MB’s:
mysql> SELECT table_schema “database”, sum(data_length + index_length)/1024/1024 “size in MB” FROM information_schema.TABLES GROUP BY table_schema;

If you want the output in GB’s:
mysql> SELECT table_schema “database”, sum(data_length + index_length)/1024/1024/1024 “size in GB” FROM information_schema.TABLES GROUP BY table_schema;

If you want to view specific database size in GB’s:
mysql> SELECT table_schema “database”, sum(data_length + index_length)/1024/1024/1024 “size in GB” FROM information_schema.TABLES WHERE table_schema=’test3′ GROUP BY table_schema;

Installing Nginx, MySQL & PHP5 (PHP5-FPM) on Ubuntu 12.04 LTS

Installing Nginx, MySQL & PHP5 (And PHP5-FPM) a.k.a (LEMP) On Ubuntu 12.04 LTS

1. Update & upgrade your OS first;

apt-get update
apt-get upgrade

  1. Install Myssql & PHP5-FPM;

apt-get install mysql-server mysql-client php5-fpm

  1. Install Nginx webserver

apt-get install nginx

  1. Start your Nginx!

/etc/init.d/nginx start


service nginx start

Try access your web via localhost or via ip

5. Edit nginx config file;

vi /etc/nginx/nginx.conf

Adjust worker proc & keepalive accordingly;

    worker_processes    4;
    keepalive_timeout    2;

  1. Edit the virtual host config;

vi /etc/nginx/sites-available/default

server {
        listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default ipv6only=on; ## listen for ipv6 if any

        root /usr/share/nginx/www; # you can change to any path you want
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                deny all;

        # Only for nginx-naxsi : process denied requests
        #location /RequestDenied {
                # For example, return an error code
                #return 418;

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/www;

        # pass the PHP scripts to FastCGI server listening on
        location ~ .php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+.php)(/.+)$;
                #fastcgi_pass fastcgi_pass;
                fastcgi_pass unix:/tmp/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

        # deny access to .htaccess files, if Apache’s document root
        # concurs with nginx’s one
        location ~ /.ht {
                deny all;

  1. Reload the config file

/etc/init.d/nginx reload

  1. Install nessary file

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache

  1. Now reload PHP-FPM:

/etc/init.d/php5-fpm reload

  1. Test your nginx;

vi /usr/share/nginx/www/info.php

Paste this line below;


  1. Try access that file via web browser

    It will show info include mysql module

    Making PHP-FPM Use A Unix Socket
    By default PHP-FPM is listening on port 9000 on It is also possible to make PHP-FPM use a Unix socket which avoids the TCP overhead. To do this, open /etc/php5/fpm/pool.d/www.conf.

    12. Edit file

vi /etc/php5/fpm/pool.d/www.conf

… and make the listen line look as follows:

;listen =
listen = /tmp/php5-fpm.sock

  1. Then reload PHP-FPM:

/etc/init.d/php5-fpm reload

Done!. Hope it helps. 🙂

Changing MySQL root user Password

Bagi sapa2 yang selalu menggunakan MySQL database,
pernah tak jadi kat korang dimana korang terlupa password ‘root’ korang?
Haa.. Aku dah terkena dah sekali..
Dan memang sangat tebaik.. Huhu..

Lalai betul aku nih..
Ntah macam mana aku boleh lupa pulak password aku..
So kat sini aku sharekan solution macam mana nak reset password untuk ‘root’ korang..

  1. Stop kan mysql service

  1. Lepas tu korang start kan balik mysql server tu supaya nanti korang boleh akses ke mysql server tu tanpa menggunakan password

  1. Connect ke mysql server dengan menggunakan mysql client

  1. Buat password baru untuk ‘root’ user

  1. Stop kan mysql server

  1. Start balik macam biasa

Haa.. Dengan mengikuti cara ni, insyallah server MySQL tu boleh diakses sebagai ‘root’ user dengan menggunakan password yang baru korang bubuh tu..