Uploading multiple files with Phalcon PHP and HTML5.

First of all, if you just fell here and don’t know what Phalcon is, I recommend you to first take a ride at its website, or documentation. If you feel ready or already knew it, then we can go on.

Note: if you want the tl;dr version you can go down the page, download the whole project and see the code by yourself.

Note²: my goal here is just show the simplest way to implement a multiple file upload system using Phalcon, so don’t expect to see security rules such as file size limiters, file extension filtering, upload bot blocking, etc.

For this example we will be using the native HTML5 multiple attribute for file inputs, which according to CanIUse, its suported by: IE10+, Chrome, Firefox, Safari 7+, iOS 5+, and Android 4.4+.

So, first of all lets create a new Phalcon project (you can create it manually or using Phalcon Dev Tools, which I highly recommend you to use, you can find more about it here).

Using Dev Tools we can simply use this command to create all Phalcon project structure and files automatically:

$ phalcon project multiple-uploader-example

Where “multiple-uploader-example” is the name you want to give to our project.

Ok, so now we have our fresh created project which will have an structure like this:

Dat Sublime Text 2 Theme…

See these green arrows pointing to IndexController.php and index.volt? These are the only files we will be working at.

Also, we need to create a folder that we will call temp inside public’s folder which will receive the uploaded files:

Ok, so now we need to create a form in the view (index.volt) to send our images, it will be something like this:

<form action=”index/upload” method=”post” enctype=”multipart/form-data”>
 <input type=”file” name=”files[]” multiple>
 <input type=”submit” value=”Send File(s)”>

The form itself is pretty common, the magic happens when we add the multiple attribute and the brackets in input’s name, now our input supports multiple files. Also, as you can see, the action is leading to index/upload which we will be coding bellow.

In our IndexController.php we now need to handle the upload action, checking if there is any file sent, and handling them properly.

Our yet untouchable IndexController.php is probably looking like this:

class IndexController extends ControllerBase
 public function indexAction()

You can see that there is already a function which responds to /index actions which is empty, now we need to create the one that will handle /index/upload. To do this we will create another action:

class IndexController extends ControllerBase
 public function indexAction()
 public function uploadAction()

And then put the code which will handle the uploaded files:

#check if there is any file
if($this->request->hasFiles() == true){
 $uploads = $this->request->getUploadedFiles();
 $isUploaded = false;
 #do a loop to handle each file individually
 foreach($uploads as $upload){
 #define a “unique” name and a path to where our file must go
 $path = ‘temp/’.md5(uniqid(rand(), true)).’-’.strtolower($upload->getname());
 #move the file and simultaneously check if everything was ok
 ($upload->moveTo($path)) ? $isUploaded = true : $isUploaded = false;
 #if any file couldn’t be moved, then throw an message
 ($isUploaded) ? die(‘Files successfully uploaded.’) : die(‘Some error ocurred.’);
 #if no files were sent, throw a message warning user
 die(‘You must choose at least one file to send. Please try again.’);

Kind of fuzzy eh? As Medium don’t support syntax highlight (yet! I hope) I think that a image of the whole controller would become handy and easier to understand:

This image is the code above in any editor with syntax highlight

Aaand this is it! Now all you need to do is run your project in a browser (in an apache environment with phalcon installed, obviously) and see the magic happens!

If you want to see what we just created here, you can download the example project here (watch out, its a .rar file, it may contain viruses that will eat you brain inside out while singing shitty pop songs).

If you got stuck somewhere or have any doubts you can always leave a comment in the part you are having troubles. →

And a good week for everyone. ☺


Raw SQL Query PhalconPHP

Phalcon is a high perfomance PHP framework based on MVC pattern.  Phalcon has good performance in handle many request/second compared to other PHP framework, such as : Laravel, Zend, Code Igniter, and Kohana.

This tutorial will show you how to call raw SQL query for insert,update,select, and delete in Phalcon PHP Framework.

1. Select

This example shows you how to call raw select from Phalcon controller class.

public function selectAction()
    $result=$this->db->query("SELECT employee_id,employee_name FROM employee order by employee_id desc");
        echo $row['employee_id']." ".$row['employee_name']."<br>";


2. Insert

This example shows you how to call raw insert from Phalcon controller class.

public function insertAction()
    $success=$this->db->execute("INSERT INTO employee (employee_id,employee_name)
                            VALUES ('14','Aditya Nugraha')");
    if($success)echo "Success!!";
    else echo "Failed!!";


3. Update

This example shows you how to call raw update from Phalcon controller class.

public function updateAction()
    $success=$this->db->execute("UPDATE employee SET employee_name='Aditya'
                                WHERE employee_id='14'");
        echo $updatedCount." rows updated";
    else echo "Failed!!";


4. Delete

This example shows you how to call raw delete from Phalcon controller class.

public function deleteAction()
    $success=$this->db->execute("DELETE FROM employee
                                WHERE employee_id='14'");
        echo $updatedCount." rows deleted";
    else echo "Failed!!";

Cara Upload Project ke Github Melalui CMD

Upload File ke Github

1. Pertama yang harus kalian lakukan adalah mendaftar akun Github terlebih dahulu. Prosesnya terbilang mudah 3 Step untuk bisa membuat akun di Github.

Disini https://github.com/

2.   Setelah berhasil di buat akun Githubnya. Lihat pada pojok kanan atas pilih tanda + samping gambar profil Github kalian. Lalu pilih New repository.

New repository Github

3. Lalu pada bagian Create a new repository . Kalian bisa isikan  Nama Repository di kolom bagian atas. Lalu bagian bawah (optional) kalian bisa mengisikan deskripsinya. Setting ke Public , jika sudah pilih tombol Create Repository yang bewarna hijau. 

Create Repository Github

4.   Jika sudah Copykan alamat atau url repository gitnya. Alamat ini akan kita gunakan untuk tempat meremote folder atau file kita di Github.

alamat atau url Github remote

5. Sekarang kembali ke Command Prompt atau Git Bash, masuk ke dalam folder dan file sebelumnya
( folder : belajargit file : latihan1.txt).

6. Lalu ketikan perintah git config

git config adalah suatu perintah untuk mengkonfigurasi username,  dan alamat email Github kita agar tersimpan di dalam Command Line.


git config cmd Windows
git config

git config –global user.name “username Github”
git config –global user.email “alamat email Github”

7.  Kemudian ketikan perintah  git init

8. Sekarang kita akan coba tambahkan 3 file tambahan. Ketikan git add * 

9.  Jika di artikel sebelumnya kita sudah menambahkan commit , sekarang kita tambahkan lagi yaitu dengan mengetikan.

 git commit –m “Upload di Github”

10.  Setelah itu kita akan meremote ke alamat , atau url repository git yang sudah kita copykan tadi.

git remote adalah perintah untuk tempat meremote folder atau file kita sebelumnya yang sudah terinisiaisasi Git, yang tersimpan di local (Komputer kita ) ke server atau tempat repository (Github)

Ketikan perintah :

git remote add origin <alamat git kalian>

//origin adalah nama remote yang telah kita tambahkan
//jika kalian ingin mengubah url remote atau mensetting kembali remote kalian bisa mengetikan perintah :
git remote set-url origin <alamat git>

git remote cmd windows
git remote

11. Lalu ketikan

 git pull origin master.


git pull digunakan untuk menarik atau nama lain dari mengunduh,  beberapa file di dalam project yang tersimpan di repository (server),  ke dalam tempat penyimpanan Komputer kita (local).


Biasanya ini digunakan untuk suatu project yang dikerjakan atau dikembangkan lebih dari satu orang (kolaboratif) , dan kita mengambil beberapa file yang telah di kerjakan oleh orang tersebut. Jadi ketika ada perubahan dan penambahan file di server atau repository Github, kalian harus menggunakan git pull terlebih dahulu sebelum mempush (git push).


12. Terakhir kita ketikan.

 git push origin master

git push digunakan untuk mengupload atau menyimpan,  beberapa file di dalam project dari  tempat penyimpanan Komputer kita (local) , ke dalam project yang tersimpan di repository (server).

Tapi tunggu dulu jika kalian memiliki kegagalan saat mempush  , atau kendala erorr dan server (Github) menolak project  kita seperti pada gambar dibawah:

git push error cmd Windows
git push error

Tenang kalian bisa mencari solusinya di forum diskusi tanya jawab.

Disini : StackOverflow.com

atau kalian bisa ketikan perintah berikut :

git reset –mixed origin/master
git add .
git commit -m “Upload Github Lagi”
git push origin master

 Jika berhasil maka tampilanya akan seperti ini :

git push sukses cmd Windows
git push sukses

Nah sekarang kita lihat ke akun github kita, Jika tampilanya seperti gambar dibawah. Maka project kita telah sukses di upload atau disimpan ke server (Repository) Github.

project sukses tersimpan atau terupload di Github
Oh ya kalian juga dapat mengkloning atau mendownload,  project Github kalian atau orang lain  lewat Command Line dengan perintah:

git clone <alamat git>

git clone alamat git
git clone

Tambahan jika kalian ingin melakukan perubahan atau penambahan :

  • 1. Jadi intinya gini jika kita ingin menambahkan folder ( harus berisi file ) atau file baru dan perubahan pada beberapa file ,kita bisa menampilkan status folder atau file tersebut dengan perintah: git status.
  • 2. Nah ketika status folder atau file tersebut terlihat maka akan di tandai dengan warna merah. Artinya folder atau file dalam mode (unstaged) belum di daftarkan ke system Git.
  • 3. Selanjutnya agar folder atau file tersebut terdaftar ke system git , dan beralih ke mode (staged) , yang dimana telah terjadi perubahan atau penambahan pada project, kita bisa mengetikan perintah git add <namafile> atau git add *.
  • 4. Setelah itu kita beri keterangan atau pesan, kepada system Git, bahwa terjadi perubahan pada project tersebut dengan perintah: git commit -m “Pesan kalian”
  • 5. Lalu baru lah kalian bisa mengupload atau menyimpan project kalian ke repository Github (Server), dengan mengetikan perintah : git push origin master.
Alur Langkah Langkah Mengupload Project ke Github
Alur Mengupload Project ke Github

Selengkapnya jika ingin melihat Basic Git Command lainya ( Perintah Dasar Git ):

Kurang lebih itu saja  tentang Cara Mengupload Project ke Github Melalui Command Line. Jika terdapat kekurangan disana sini mohon maaf sebelumnya. Terima kasih.

How to Install PHP 7 on CentOS/RHEL 7.1 & 6.7

PHP 7.1 is the latest stable release of PHP. May of popular yum repositories are providing rpm packages for PHP 7. This article is using webtatic yum repository and used the same for testing on CentOS 7 server. This article will help you to install PHP 7 on CentOS & Red Hat 7.1 & 6.7 servers.

Install Yum Repository

First of all you need to enable Webtatic and EPEL yum repositories on your system. Use the following command to install EPEL repository on your CentOS and Red Hat 7/6 systems

Use this command to install epel-release yum repository.

# yum install epel-release

and now execute one of the following command as per your operating system version to install webtatic yum repository.

On CentOS/RHEL 7:

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

On CentOS/RHEL 6:

# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

Install PHP 7

Use the following command to install PHP 7 on your system.

# yum install php70w

Verify Install PHP Version

Now use the following command to check installed PHP version on your system.

# php -v

PHP 7.0.0 (cli) (built: Dec  2 2015 20:42:32) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

Install PHP Modules

You may also want to install additional php modules based on your application requirements. Below command will install some more useful php modules.

# yum install php70w-xml php70w-soap php70w-xmlrpc
# yum install php70w-mbstring php70w-json php70w-gd php70w-mcrypt

To find out other available php modules use the following command.

# yum search php70 

php70w.x86_64 : PHP scripting language for creating dynamic websites
php70w-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php70w-cli.x86_64 : Command-line interface for PHP
php70w-common.x86_64 : Common files for PHP
php70w-dba.x86_64 : A database abstraction layer module for PHP applications
php70w-devel.x86_64 : Files needed for building PHP extensions
php70w-embedded.x86_64 : PHP library for embedding in applications
php70w-enchant.x86_64 : Enchant spelling extension for PHP applications
php70w-fpm.x86_64 : PHP FastCGI Process Manager
php70w-gd.x86_64 : A module for PHP applications for using the gd graphics library
php70w-imap.x86_64 : A module for PHP applications that use IMAP
php70w-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird databases
php70w-intl.x86_64 : Internationalization extension for PHP applications
php70w-ldap.x86_64 : A module for PHP applications that use LDAP
php70w-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php70w-mcrypt.x86_64 : Standard PHP module provides mcrypt library support
php70w-mysql.x86_64 : A module for PHP applications that use MySQL databases
php70w-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php70w-odbc.x86_64 : A module for PHP applications that use ODBC databases
php70w-opcache.x86_64 : An opcode cache Zend extension
php70w-pdo.x86_64 : A database access abstraction module for PHP applications
php70w-pdo_dblib.x86_64 : MSSQL database module for PHP
php70w-pear.noarch : PHP Extension and Application Repository framework
php70w-pgsql.x86_64 : A PostgreSQL database module for PHP
php70w-phpdbg.x86_64 : Interactive PHP debugger
php70w-process.x86_64 : Modules for PHP script using system process interfaces
php70w-pspell.x86_64 : A module for PHP applications for using pspell interfaces
php70w-recode.x86_64 : A module for PHP applications for using the recode library
php70w-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
php70w-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php70w-tidy.x86_64 : Standard PHP module provides tidy library support
php70w-xml.x86_64 : A module for PHP applications which use XML
php70w-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

credit : tecadmin.net

Install Latest PhpMyAdmin in RHEL/CentOS 7/6 and Fedora 24-20

MySQL administration via command-line in Linux is very difficult job for any newbie system administrator or database administrator, because it contains numerous commands which we cannot remember in our daily life.

Suggested Read: MySQL Basic Database Administration Commands

To make MySQL administration much easier we’re introducing a web based MySQL administration tool called PhpMyAdmin, with the help of this tool you can control and manage your database administration via a web browser easily.

PhpMyAdmin is a web-based interface for managing MySQL / MariaDB databases that is used as a replacement for command-line utilities.

Suggested Read: 20 MySQL (Mysqladmin) Commands for Database Administration in Linux

It was written in PHP language, through this application you can do various MySQL administration tasks such as create, drop, alter, delete, import, export, search, query, repair, optimize and run other database management command via browser.

As other well-known web-based interfaces for managing system services, blog creation tools, or content management systems (CMSs), it is often targeted by malicious attackers who seek to exploit the usual lack of security measures.

In this article we’re going to show you how to install latest stable version of PhpMyAdmin for Apache or Nginx on RHEL, CentOS and Fedora distributions.

Here we’ve provided installation of PhpMyAdmin for both the web server’s Apache or Nginx. So, its up-to you which web server to choose for installation.

But do remember that, you must have working LAMP (Linux, Apache, PHP and MySQL/MariaDB) or LEMP (Linux, Nginx, PHP and MySQL/MariaDB) setup installed on your working system.

If you don’t have working LAMP or LEMP, you can follow our below articles to setup.

Install LAMP Stack

  1. Install LAMP Stack on RHEL/CentOS 7/6 & Fedora 24-18

Install LEMP Stack

  1. Install LEMP Stack on RHEL/CentOS 7/6 & Fedora 24-18

Step 1: Install EPEL and Remi Repositories

1. To install most recent version of PhpMyAdmin (i.e. 4.6), you need to install and enable EPEL and Remi repositories on your respective Linux distributions as shown:

On RHEL/CentOS 7

# rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 

On RHEL/CentOS 6

-------------- On RHEL/CentOS 6 - 32-bit --------------
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
-------------- On RHEL/CentOS 6 - 64-bit --------------
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

On Fedora 20-24

# rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-24.rpm   [On Fedora 24]
# rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-23.rpm   [On Fedora 23]
# rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-22.rpm   [On Fedora 22]
# rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-21.rpm   [On Fedora 21]
# rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-20.rpm   [On Fedora 20]

Step 2: Installing PhpMyAdmin Web Interface

2. Once you’ve installed above repositories, now its’ time to install PhpMyAdmin with the help of following command as shown.

# yum --enablerepo=remi install phpmyadmin

Note : If your are using PHP 5.4 on RHEL/CentOS/Fedora systems, then you need to run the below command to install it.

# yum --enablerepo=remi,remi-test install phpmyadmin

Step 3: Configuring PhpMyAdmin for Apache or Nginx

In Apache you don’t need to configure anything for phpMyAdmin, because you will get working phpMyAdmin automatically at the address http://<ip address>/phpmyadmin.

Suggested Read: MySQL Backup and Restore Commands for Database Administration

The main configuration file is located under /etc/httpd/conf.d/phpMyAdmin.conf, make sure the Require all granted directive (For Apache 2.4) and Allow from &ltip address> is added inside the Directory /usr/share/phpmyadmin block.

PhpMyAdmin Allow Access

Finally, restart Apache to apply changes.

-------------- On RHEL/CentOS 7 and Fedora 22-24 --------------
# systemctl restart httpd
-------------- On RHEL/CentOS 6 and Fedora 20-21 --------------
# service httpd restart

On the Nginx web server, we will create a symbolic link to PhpMyAdmin installation files to our Nginx web document root directory (i.e. /usr/share/nginx/html) by running the following command:

# ln -s /usr/share/phpMyAdmin /usr/share/nginx/html

Finally, restart Nginx and PHP-FPM to apply changes.

-------------- On RHEL/CentOS 7 and Fedora 22-24 --------------
# systemctl restart nginx
# systemctl restart php-fpm
-------------- On RHEL/CentOS 6 and Fedora 20-21 --------------
# service nginx restart
# service php-fpm restart

Step 4: Accessing PhpMyAdmin Web Interface

Open your browser and point your browser to http://<ip address>/phpmyadmin. It should open the phpmyadmin interface (as shown in the image below).

PhpMyAdmin Running on Fedora 24

In the next articles, we will share some tips to secure your phpmyadmin installation on a LAMP or LEMP stack against the most common attacks carried out by malicious individuals.

Read Also: How to Secure Default PhpMyAdmin Login URL


credit : http://www.tecmint.com

Cara Install Latest MySQL 5.7.9 on RHEL/CentOS 7/6/5 and Fedora 23/22/21

This article will walk through you the process of installing and updating latest MySQL 5.7.9 version on RHEL/CentOS 7/6/5 and Fedora 23/22/21 using MySQL Yum repository via YUM utility.

Step 1: Adding the MySQL Yum Repository

1. We will use official MySQL Yum software repository, which will provides RPM packages for installing the latest version of MySQL server, client, MySQL Utilities, MySQL Workbench, Connector/ODBC, and Connector/Python for the RHEL/CentOS 7/6/5 and Fedora 23-21.

Important: These instructions only works on fresh installation of MySQL on the server, if there is already a MySQL installed using a third-party-distributed RPM package, then I recommend you to upgrade or replace the installed MySQL package using the MySQL Yum Repository”.

Before Upgrading or Replacing old MySQL package, don’t forget to take all important databases backup and configuration files.

2. Now download and add the following MySQL Yum repository to your respective Linux distribution system’s repository list to install the latest version of MySQL (i.e. 5.7.9 released on 21 October 2015).

--------------- On RHEL/CentOS 7 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
--------------- On RHEL/CentOS 5 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-el5-7.noarch.rpm
--------------- On Fedora 23 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm
--------------- On Fedora 22 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-fc22-7.noarch.rpm
--------------- On Fedora 21 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-fc21-7.noarch.rpm

3. After downloading the package for your Linux platform, now install the downloaded package with the following command.

--------------- On RHEL/CentOS 7 ---------------
# yum localinstall mysql57-community-release-el7-7.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
# yum localinstall mysql57-community-release-el6-7.noarch.rpm
--------------- On RHEL/CentOS 5 ---------------
# yum localinstall mysql57-community-release-el5-7.noarch.rpm
--------------- On Fedora 23 ---------------
# dnf localinstall mysql57-community-release-fc23-7.noarch.rpm
--------------- On Fedora 22 ---------------
# dnf localinstall mysql57-community-release-fc22-7.noarch.rpm
--------------- On Fedora 21 ---------------
# yum localinstall mysql57-community-release-fc21-7.noarch.rpm

The above installation command adds the MySQL Yum repository to system’s repository list and downloads the GnuPG key to verify the integrity of the packages.

4. You can verify that the MySQL Yum repository has been added successfully by using following command.

# yum repolist enabled | grep "mysql.*-community.*"
# dnf repolist enabled | grep "mysql.*-community.*"      [On Fedora 22+ versions]

Verify MySQL Yum Repository

Step 2: Installing Latest MySQL Version

5. Install latest version of MySQL (currently 5.7) using the following command.

# yum install mysql-community-server
# dnf install mysql-community-server      [On Fedora 22+ versions]

The above command installs all the needed packages for MySQL server mysql-community-server, mysql-community-client, mysql-community-common and mysql-community-libs.

Step 3: Installing MySQL Release Series

6. You can also install different MySQL version using different sub-repositories of MySQL Community Server. The sub-repository for the recent MySQL series (currently MySQL 5.7) is activated by default, and the sub-repositories for all other versions (for example, the MySQL 5.6 or 5.5 series) are deactivated by default.

To install specific version from specific sub-repository, you can use --enable or --disable options using yum-config-manager or dnf config-manager as shown:

# yum-config-manager --disable mysql57-community
# yum-config-manager --enable mysql56-community
------------------ Fedora 22+ Versions ------------------
# dnf config-manager --disable mysql57-community
# dnf config-manager --enable mysql56-community

Step 4: Starting the MySQL Server

7. After successful installation of MySQL, it’s time to start the MySQL server with the following command:

# service mysqld start

You can verify the status of the MySQL server with the help of following command.

# service mysqld status

This is the sample output of running MySQL under my CentOS 7 box.

Redirecting to /bin/systemctl status  mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Thu 2015-10-29 05:15:19 EDT; 4min 5s ago
Process: 5314 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 5298 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 5317 (mysqld)
CGroup: /system.slice/mysqld.service
└─5317 /usr/sbin/mysqld --daemonize
Oct 29 05:15:19 localhost.localdomain systemd[1]: Started MySQL Server.

Check Mysql Status

8. Now finally verify the installed MySQL version using following command.

# mysql --version
mysql  Ver 14.14 Distrib 5.7.9, for Linux (x86_64) using  EditLine wrapper

Check MySQL Installed Version

Step 5: Securing the MySQL Installation

9. The command mysql_secure_installation allows you to secure your MySQL installation by performing important settings like setting the root password, removing anonymous users, removing root login, and so on.

Note: MySQL version 5.7 or higher generates a temporary random password in /var/log/mysqld.log after installation.

Use below command to see the password before running mysql secure command.

# grep 'temporary password' /var/log/mysqld.log

Once you know the password you can now run following command to secure your MySQL installation.

# mysql_secure_installation

Note: Enter new Root password means your temporary password from file /var/log/mysqld.log.

Now follow the onscreen instructions carefully, for reference see the output of the above command below.

Sample Output
Securing the MySQL server deployment.
Enter password for user root: Enter New Root Password
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: Set New MySQL Password
Re-enter new password: Re-enter New MySQL Password
Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
- Removing privileges on test database...
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
All done! 

Step 6: Connecting to MySQL Server

10. Connecting to newly installed MySQL server by providing username and password.

# mysql -u root -p

Sample Output:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.7.9 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
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Connect to MySQL Server

Step 7: Updating MySQL with Yum

11. Besides fresh installation, you can also do updates for MySQL products and components with the help of following command.

# yum update mysql-server
# dnf update mysql-server       [On Fedora 22+ versions]

Update MySQL Version

When new updates are available for MySQL, it will auto install them, if not you will get a message saying NO packages marked for updates.

That’s it, you’ve successfully installed MySQL 5.7.9 on your system. If you’re having any trouble installing feel free to use our comment section for solutions.


credit : www.tecmint.com