ERROR 1045 (28000): Access denied for user

My local MySQL has no password for root user. I have added a new user with password and I’m trying to login to MySQL. This is what I got!

G:\XAMPP\mysql\bin>mysql -ugaja -p
Enter password: ****************
ERROR 1045 (28000): Access denied for user ‘gaja’@’localhost’ (using password: YES)

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

What I have done?

  1. Stop Mysql from XAMPP console
  2. Start the mysql from command line as given below
    g:\xampp\mysql\bin\mysqld.exe --skip-grant-tables
  3. From another cmd I logged in to Mysql
    mysql -u root
  4. Set the password string for root user
    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    FLUSH PRIVILEGES;
  5. Check if passwordless login is allowed still.
    G:\XAMPP\mysql\bin>mysql -u root
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  6. Lets login with password now
    G:\XAMPP\mysql\bin>mysql -u root -p
    Enter password: ********
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 4
    Server version: 5.6.21 MySQL Community Server (GPL)
  7. Remove the anonymous user account
    DROP USER ''@'localhost';
  8. Let me try to login with the user I’ve created newly
    G:\XAMPP\mysql\bin>mysql -u gaja -p
    Enter password: ****************
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.21 MySQL Community Server (GPL)

Enjoy!

Unable to find the wrapper “https” – did you forget to enable it when you configured PHP?

IMAG0659

When I try to connect to a website with SSL, I got this problem

Unable to find the wrapper “https” – did you forget to enable it when you configured PHP?

This is the method I call in my code.

$httpsfile = file_get_contents("https://customer.ccccc.com/");
I had to add the following line to my php.ini file located in xammp/php/php.ini.

extension=php_openssl.dll

Apache VirtualHosts – HowTo

IMAG0652

I used to do this whenever I make a new PHP project. But I forget the steps often. This post will explain you how to add a new virtual host in apache.

1. Apache server installed (I’ve used XAMPP ) with php plugin enabled

2. Make a new folder in your computer. Ensure you have an index.html or index.php on that folder. I’ve my folder on C:\xampp\htdocs\market

3. Make the following steps on C:\xampp\apache\conf\extra\httpd-vhosts.CONF file. This will be the file to define your virtual hosts

Add the following lines at the end of this file.

#this is to access the standard xampp home page
NameVirtualHost localhost:80
<VirtualHost localhost>
ServerAdmin pandian@grassfield.org
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
#ServerAlias http://www.dummy-host.localhost
#ErrorLog "logs/dummy-host.localhost-error.log"
#CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>

#this is our virtual host grassfield.dev
NameVirtualHost grassfield.dev:80
<VirtualHost grassfield.dev>
ServerAdmin pandian@grassfield.org
DocumentRoot "C:\xampp\htdocs\market"
ServerName grassfield.dev
#ServerAlias http://www.grassfield.dev
#ErrorLog "logs/grassfield.dev-error.log"
#CustomLog "logs/grassfield.dev-access.log" combined
</VirtualHost>

4. Restart the apache service

5. Access http://localhost and http://grassfield.dev sites are rendered correctly on the browser. Sample file is attached in this post.

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/&gt;
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
NameVirtualHost localhost:80
<VirtualHost localhost>
ServerAdmin pandian@grassfield.org
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
#ServerAlias http://www.dummy-host.localhost
#ErrorLog "logs/dummy-host.localhost-error.log"
#CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>
##<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
##DocumentRoot "C:/xampp/htdocs/dummy-host2.localhost"
##ServerName dummy-host2.localhost
##ServerAlias http://www.dummy-host2.localhost
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
##</Virtual
NameVirtualHost grassfield.dev:80
<VirtualHost grassfield.dev>
ServerAdmin pandian@grassfield.org
DocumentRoot "C:\xampp\htdocs\market"
ServerName grassfield.dev
#ServerAlias http://www.grassfield.dev
#ErrorLog "logs/grassfield.dev-error.log"
#CustomLog "logs/grassfield.dev-access.log" combined
</VirtualHost>

The picture at the top don’t have any relations with this post 😉