Resolving “cannot connect to database” error of wordpress after upgrading from Ubuntu 12.04 LTE to 14.04 LTE

Share Button

I upgraded my server from Ubuntu 12.04 LTE to 14.04 LTE. But after that, I cannot access my wordpress site any more. This gave a headache for a whole night. After trying tons of methods, finally I figured it out how to resolve it. But still not sure what happened though. So my issue is I keep getting “cannot connect to database” error.

First of all, I tried to check if mysql is installed correctly, and see if I can log in mysql using root. The answer is yes. But strangely I cannot log in using the user name and password wordpress is using. I also checked mysql wp_* tables, and they are all there. So it must be something with user name and password. I basically tried all method on http://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/. But no matter I access www.ycshao.com or www.ycshao.com/wp-admin or http://www.ycshao.com/wp-admin/maint/repair.php, I always get “cannot connect to database”.

I know it’s something wrong with my wp-config.php, but I couldn’t figure out why. So I tried following solution which worked eventually for me.

  1. I backed up old wp-config.php, and it will let you generate new wp-config.php.
  2. When I accessed www.ycshao.com, the initial setup screen showed up! I tried to setup database name, user name, password, database host and table prefix according to DB_NAME, DB_USER, DB_PASSWORD, DB_HOST and table_prefix variables in wp-config.php. But no luck, I still could not connect to database.
    install-step3
  3. Then I created new mysql user and password
  4. Then I repeated step 1 and 2. Magically it worked! Everything comes back!

It took me 3 hours 22 minutes.

 

How to setup name-based virtual host on Ubuntu server.

Share Button

I’m moving my site from fatcow.com to linode.com because I setup VPS on linode so I’ll have more control of it. The first step is to setup name-based virtual host so that I can link my sub-domains to my “www” sub-directories.

  1. Create DNS records for domains and sub-domains. The IP address of sub-domains can be the same as your main domain.
  2. Now the world know how to resolve your domain name to an IP address, next step is to create name-based virtual host on Ubuntu server so that we can host different sites on different sub-domains. I want to create 2 sites. One is my main domain which host my blog www.ycshao.com, another one is for testing purpose image.ycshao.com.
  3. Enable name-based virtual host on Ubuntu:

    and add following line to the end if it’s not there
  4. There are two folders in /etc/apache2, which are sites-available and sites-enabled. Usually sites-enabled folder will have soft link to files in sites-available folder. The folder names are pretty obvious, “available” means available sites and “enabled” means  sites which can be accessed. Let’s start from scratch.

    and modify first few lines to

    The most important things are your “ServerName” corresponding to url you want to set and “DocumentRoot” corresponding to which directory this url points to. Then make a soft link to enable this site:
  5. Now you should be able to access www.ycshao.com and it should go to my wordpress blog sitting in /var/www/wordpress.
  6. Now repeat step 4 for image.ycshao.com and other sites you want to configure.

How to open .ica file and setup Citrix client on Ubuntu.

Share Button

The Citrix ICA Client (=Citrix Receiver) allows access to remote Windows sessions run from a Citrix server. If you want to open .ica file using ICA client on Ubuntu, here is what you should do:

  1. Download and install the 32-bit version of libmotif3 and create a symlink:
  2. Download the Citrix Receiver 12.1 .deb files for ‘Receiver for Linux 12.1 from:http://www.citrix.com/English/ss/downloads/details.asp?downloadId=2323812&productId=1689163
  3. Run hdxcheck.sh, which was installed with the Citrix Receiver:

    Look back through the messages displayed to check that it found libjpeg.so, as it might fail to do so despite it being installed. If it failed to find it then you can edit /opt/Citrix/ICAClient/util/hdxcheck.sh and change
    Lib=find *libjpeg.so*
    to
    Lib=find / -name *libjpeg.so*
    and run  hdxcheck.sh again.
  4.  Firefox will using ICA client to open .ica file, or you can manually choose /opt/Citrix/ICAClient/wfica.sh to open .ica file.

Reference:
 CitrixICAClientHowTo

Mount missing partitions in Ubuntu 11.10

Share Button

I found that one of my partition in windows was missing in Ubuntu, so I tried to mount it back. Firstly type:

to check what are partitions available. And I figured out that sda4 is the partition missing, so I tried

But it gave me:

Maybe it’s because auto-mount performed by Ubuntu somehow grab the handle, so I unmounted this partition first and mounted it back by:

 

Install opencv on linux

Share Button
  • If you don’t care about getting the cutting-edge version of opencv, you can do following:

    To compile examples:
  • If you’re geek enough to pursue newest version of everything like me, you may have to spend a little more time on this:
    To check out code from opencv svn repository: (you need to install svn first) 

     To build libraries, you need to install cmake/cmake-gui first:

    Then we can build libraries using cmake:

    In cmake-gui,  check whatever you need(if you are not sure, you can just leave it default), click configure. After “Configuring done”, click generate. If you see “Generating done”, you are good to do next step:

    Wait until it’s done.
    After you build opencv libraries, we’re ready to use them:
    Let’s begin with a hello world test program named helloWorld.cpp:

    Then we create a CMakeLists.txt in the same directory as follows:

    Then use cmake to generate makefile and use make to generate executable:

    And you are done! Run it and you’ll see a hello world window.

  • If you want to use opencv libraries in Eclipse, right click your project and select properties. In c/c++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Includes, add your opencv include dir into Include paths (-I). Then in  GCC C++ Linker -> Libraries, add libraries(such as opencv_core, opencv_highgui, your library names may var) to Libraries (-l) and your libraries dir to Library search path (-L).
    BWT, you can use these commands to locate your include files and libraries: 

Reference:

OpenCV – Ubuntu Doc

OpenCV install guide

Fix gvim slowness bug in Ubuntu 11.10

Share Button

After I upgrade to Ubuntu 11.10, I found that gvim acted very slow. To fix this, simply use

instead of

Setup ubuntu 11.10 environment

Share Button

I installed ubuntu 11.10 32bit version, but found there were few things that did not as good as previous version, something like sound-too-low problem, cannot see text due to black background tooltip of default theme, and etc. So I spent quite a lot of time to fix those problem and setup environment.
1. Install advanced linux terminal: Terminator. It has split view, tabs and other advanced feature.
2. Install Adwaita theme to fix the tooltip problem, and it also fixed the same problem in autocomplete frame of eclipse.
3. To fix sound-too-low problem, enter “alsamixer” in linux terminal  and adjust all volume to max. But remember don’t adjust the last two mic volume to max, otherwise, there will be harsh sound.
4. Install chrome, eclipse, vlc, Task Manager and etc.