Saturday, April 9, 2016

Using winscp for transferring files to amazon ec2 instance in windows desktop

Before we start you need to download winscp and puttygen tools

Convert you amazon pem key (ssh key) from pem to ppk file. you will get this pem key from amazon console whenever you create the new instance.
  • Start PuttyGen
  • Select "import key" under "conversations" tab from the top menu.
  • Browse and select your pem file.
  • Click on "Save Private Key" to save private key as ppk file. 

  • Install WinScp using default settings/options. 
  • Enter username and hostname (username is generally ec2-user in default OS at AWS, and hostname can be noted from aws console)
  • Click on the "advaced" button and go to "authentication" menu option.
  • Browse and select your newly created ppk file at "Private key file" box and click OK.
  • Connect/ Login to the host

Monday, January 11, 2016

Reset mysql root password | bash: mysqld_safe: command not found

Installed new mysql-server (like i did mysql  Ver 14.14 Distrib 5.7.10) and forgot the root password for mysql. here are tried steps to get your access back.

[root@buggzbox amit] systemctl stop mysqld
[root@buggzbox amit] systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
[root@buggzbox amit] systemctl start mysqld
[root@buggzbox amit] mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>UPDATE mysql.user SET authentication_string = PASSWORD('newpassword') WHERE User = 'root' AND Host = 'localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@buggzbox amit]# systemctl stop mysqld;
[root@buggzbox amit]# systemctl unset-environment MYSQLD_OPTS
[root@buggzbox amit]# systemctl start mysqld
[root@buggzbox amit]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ^DBye
[root@buggzbox amit]#