Showing posts with label Password. Show all posts
Showing posts with label Password. Show all posts

Friday 20 September 2019

How to change root password of mysql

sudo service mysql stop
sudo mkdir -p /var/run/mysqld

sudo chown mysql:mysql /var/run/mysqldsudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u rootmysql> FLUSH PRIVILEGES;
mysql> USE mysql;mysql> UPDATE user SET authentication_string=PASSWORD("<Your Password>") WHERE User='root';mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
mysql> exit
sudo pkill mysqldsudo service mysql start

Thursday 7 June 2018

How to reset MySQL / phpmyadmin root password on Ubuntu 18.04 Linux

1. The simplest approach to reset MySQL database root password is to execute mysql_secure_installation program and when prompted entering your new root MySQL password:
sudo mysql_secure_installation

New password:
Re-enter new password:
2. Let's stop the currently running MySQL database:
sudo service mysql stop
3. create a /var/run/mysqld directory to be used by MySQL process to store and access socket file:
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld 
4. Start manually MySQL with the following linux commands :
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
5. Confirm that the process is running as expected: 
jobs
6. Access MySQL database without password 
mysql -u root
7. First flush privileges MySQL session
mysql> FLUSH PRIVILEGES;
8. The following commands will reset MySQL root password to "root" 
mysql> USE mysql;
mysql> UPDATE user SET authentication_string=PASSWORD("root") WHERE User='root';
mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
9. Exit MySQL session: 
mysql> exit
10. Terminate current mysqld process 
sudo pkill mysqld
11. Start MYSQL database:
sudo service mysql start
12. If all went well you should now be able to login to your MySQL database with a root password: 
mysql -u root --password=root
mysql> exit

Tuesday 5 June 2018

shell_exec("mysql -u $dbuser --password='$dbpassword' --host='$sqlhost' $dbname < $file") not working in PHP

I try to execute query from PHP / CMD / Terminal


mysql -u admin --password='jaydip' --host='localhost' 'mg_kansagra' < '/var/www/html/magento/dump/db.sql'


Its show me following error

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 3167 (HY000) at line 17: The 'INFORMATION_SCHEMA.SESSION_VARIABLES' feature is disabled; see the documentation for 'show_compatibility_56'

ANSWER

Run the following query in your MySQL database:
set @@global.show_compatibility_56=ON;

Friday 6 November 2015

Disable mod_rewrite for subdirectory OR Set Apache Password Protected Directories With .htaccess File OR API Protected


If you don't know the username and password to enter, then you can't access the page or site - it's "password protected". It's sometimes handy to be able to password protect your pages like this - for example:


  1. You're building a new site, but you only want yourself (and maybe a select few) to be able to view the work-in-progress.
  2. You have an area of your site that you never want the general public to have access to - for example, your web stats or private pages.
  3. You have some paid (subscription) content on your site that only subscribers should be able to access.
  4. Apache lets you password protect individual files, folders, or your entire site fairly easily. Read on to find out how it's done.


  1. Create a special file called .htaccess in the folder you want to protect.
ErrorDocument 401 "Unauthorized"
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/*/public_html/directory/.htpasswd
require user myusername_same_as_.htpasswd_file
     2. Creating the password file Called .htpasswd
The first step is to create a simple text file that will store your username and password, separated by a colon (:). The small catch is that the password must be encrypted. Luckily, there are many free web-based utilities that will encrypt the password for you. Try one of these:
myusername_same_as_.htaccess_file:$apr1$TSQAiMQm$MIJ.m3qpJ3mnY6NXdzppz.