Create New User and Grant Permissions in MySQL

MySQL is an open source relational database management software. It helps to store, organise and retrieve data. MySQL has a feature for you to create users to manage different databases or tables with certain permissions.

MySQL Permissions

The different types of permissions available in MySQL are as follows.

[su_table]

Permission Description
ALL PRIVILEGES allows user to perform all the following permissions on tables or databases
CREATE allows user to create tables or databases
DROP allows user to delete tables or databases
DELETE allows user to delete rows from tables
INSERT allows user to insert rows to tables
SELECT allows user to retrieve rows to tables
UPDATE allows user to update rows to tables
GRANT OPTION allows user to grant or remove other users’ privileges

[/su_table]

How to create a new user

Before being able to run any of these commands, you will have to login to your MySQL first, which usually we will use root to login at command line.

It should prompt you to enter your root password for MySQL. After that, you will be logged into your MySQL.

Command to create a new user

  • new_username – username of user
  • localhost – location in terms of ip address of MySQL to create user at
  • password – password for user to login to MySQL

After creating a new user in MySQL, we need to give the user permissions in order for the user to do anything.

  • new_username – username of user created previously
  • localhost – location in terms of ip address of MySQL where user was created at previously

Once you are done with the two commands above, you need to reload the permissions for MySQL.

 

That’s it! You are all set.

Feel free to drop me an email at [email protected] if you have any questions.

Install and Secure phpMyAdmin on CentOS 6.4

PhpMyAdmin is a popular web interface for web developers to manage MySQL databases. This tutorial will guide you through on how to install and secure PhpMyAdmin on your CentOS web server.

Pre-requisites

This guide assumes that you already have Apache and MySQL installed on your CentOS web server.
(Optional) Note that if you want to access PhpMyAdmin using SSL, then you will need to configure SSL certificate by referring to the following guide.

Setting up an SSL Secured Web Server with CentOS

1. Add EPEL Repositories

PhpMyAdmin is not included in CentOS packages, therefore you will need to add EPEL (Extra Packages for Enterprise Linux) to your web server.

(Optional) Run the following command to install wget if you haven’t install wget yet

Command to install EPEL packages to your web server

Check that EPEL has been added to your repository

You should see the following

Once done remove the respository configuration package

2. Download PhpMyAdmin

Command to download PhpMyAdmin

3. Configure PhpMyAdmin

Find your IP Address first
Then edit PhpMyAdmin config file

Modify the following 4 lines in the config file

Then save and close the config file

4. Open PhpMyAdmin in your Web Browser

Open the following url in your web browser

 

That’s it you are done!

Feel free to contact me at [email protected] if you have any questions.

Install Linux, Apache, MySQL, PHP (LAMP) stack on Debian

LAMP stack is a group of open source softwares used to get web servers up and running. This guide assumes that you already have your Debian installed successfully.

Pre-requisite

Update your OS before install the LAMP stack

1. Install Apache

Apache is the web server in the lamp stack.

Install apache command

(Optional) Test if apache is alive

Get your IP address first

Then open the following url in your web browser

2. Install MySQL

MySQL is the database management system used in LAMP stack.

Install MySQL command

Finish MySQL installation by running this

This will prompt you for your current MySQL root password, which you will most likely have none, because you have just installed MySQL only. So just leave it blank by pressing enter.

Next a series of yes/no questions will appear. All you have to do is just say Yes to all the options.

3. Install PHP

Install PHP command

Finish up by restarting apache

4. Test if PHP is working on your server

By default apache web root directory is at /var/www/html

Create a file called info.php 

(Optional) If nano is not installed yet

Add the following code to info.php

Then save and exit

Restart Apache and visit the url on your web browser as follows

Then you should see your server’s php information

 

Feel free to contact me at [email protected] if you have any further questions.

 

 

 

 

Setting up an SSL secured Webserver with CentOS

This guide will teach you how to configure and setup your own SSL certification on your CentOS web server.

1. Install required software

Use yum to get the following software if its not yet installed on your web server.

yum install mod_ssl openssl

2. Generate a self-signed certificate

The following steps guides you on how to generate your own self-signed certificate.

Generate private key

openssl genrsa -out ca.key 2048

Generate CSR

openssl req -new -key ca.key -out ca.csr

Generate self-signed key

openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

Copy the files to the respective locations

cp ca.crt /etc/pki/tls/certs

cp ca.key /etc/pki/tls/private/ca.key

cp ca.csr /etc/pki/tls/private/ca.csr

In cased you have moved the files and not copied them, use the following command to correct SELinux

restorecon -RvF /etc/pki

Update Apache SSL configuration file

sudo nano +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf

Modified the paths to match where the new Key is stored

SSLCertificateFile /etc/pki/tls/certs/ca.crt

Then set the correct path for Certification Key file

SSLCertificateKeyFile /etc/pki/tls/private/ca.key

Finally quit and save the file then restart Apache

sudo service httpd restart

3. Configure firewall

The last step to setting up your own SSL certificate is to configure the firewall to accept requests from port 443, which is used for SSL connections.

Command to accept port 443 requests

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

Save ip table

/sbin/service iptables save

iptables -L -v

 

That’s it! Your web server is now configured and ready for SSL connections.

Feel free to drop me any questions you have at [email protected]

 

Install Linux, Apache, MySQL, PHP (LAMP) stack on CentOS 6

LAMP stack is a group of open source softwares used to get web servers up and running. This guide assumes that you already have your CentOS installed successfully.

1. Install Apache

Apache is the web server in the lamp stack.

Install apache command

Start apache on your server

(Optional) Test if apache is alive

Get your IP address first

Then open the following url in your web browser

2. Install MySQL

MySQL is the database management system used in LAMP stack.

Install MySQL command

Start MySQL service

Set a root MySQL password

This will prompt you for your current MySQL root password, which you will most likely have none, because you have just installed MySQL only. So just leave it blank by pressing enter.

Next a series of yes/no questions will appear. All you have to do is just say Yes to all the options.

3. Install PHP

Install PHP command

(Optional) Install additional php modules

Search for PHP modules command

Next a bunch of php modules with their description will appear. So just use yum to install which ever modules that you want.

4. Configure Apache and MySQL to run on boot

5. Test if PHP is working on your server

By default apache web root directory is at /var/www/html

Create a file called info.php 

(Optional) If nano is not installed yet

Add the following code to info.php

Then save and exit

Restart Apache and visit the url on your web browser as follows

Then you should see your server’s php information

 

Feel free to contact me at [email protected] if you have any further questions.

Install APC (Alternative PHP Cache) in CentOS 5/6/7 and Fedora 20/21

APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes.

phpapc

1. Install Dependency Packages for APC

2. Install APC using PECL (PHP Extension Community Library)

Press “Enter” for the following options

2a. [Alternative]

If the above command fails, you can use the following method to install APC as well.

3. Enable APC PHP Extension

4. Restart Apache Service for APC

CentOS

Fedora

5. Verify APC Installation

Create a file named phpinfo.php in Apache web root directory. For example our Apache web root directory is /var/www

And add the following code to the php file

[Optional] If you do not have nano installed

Open the following url in your web browser

Screen Shot 2015-08-02 at 2.48.22 pm

 

6. Enable PHP APC administration

Copy the following file to any web directory that you want. For example, in this case we will copy it to the web root directory.

Open the file apc.php 

In nano editor, use “Ctrl-w” to search for the username and password field to modify.

Open the following link in your web browser.

You should see your APC stats and that’s it!

 

Installing Webmin on CentOS/RHEL 5/6/7 and Fedora 20/21

Wedmin is a web-based interface for you to manage your linux systems. It allows you to setup user accounts, configure cron jobs, manage Apache and many more.

webmin-logo

1. Download Webmin RPM

2. Install Webmin using RPM Command

3. Access Webmin in Browser

Additional Information

Below are the commands to start, stop, restart and get status of Webmin service

5 Common Server Setups For Your Web Application

When you are planning for a web application system architecture, there are a few things that you have to take note of.

  1. Scalability
  2. Maintainability
  3. Availability
  4. Cost
  5. Reliability
  6. Performance

 

So there are 5 common server setups as follows:

  1. Everything on one server

Having everything on one server is the most traditional way of having a web application done. This is the easiest method to get things done compared to the rest of the setups. The down side of this is that scalability is almost impossible.

  1. Separate database server

Separate database server means splitting up the web application from the database, where the database will reside on a standalone server and the same goes for the web application. This way you are able to scale the database server if you are getting way more traffic than you could have expected.

  1. Load balancer (reverse proxy)

The purpose of a load balancer is to balance the load of the incoming traffic to your web application. So having a load balancer can help you balance out the incoming traffic to the army of servers that you have. This also mean that you have to deploy multiple servers of your web application.

  1. HTTP Accelerator (caching reverse proxy)

This setup works very similar to the previous method, but the catch to this setup is that the load balancer actually caches the responses from the web application. So eventually if the same request occurs again, the load balancer is able to return the response in a shorter amount of time possible.

  1. Master-Slave database replication

This setup involves the database layer of the system architecture, where you have to two copies of your database on different servers respectively. There will be a master database and a slave database, where the master database is able to process both read and write operations and the slave database only able to process read operations. You must be wondering so how do we get the data synchronised across both databases? Thats where the key word master-slave database replication comes into the picture. Having this setup means, for every write operation on your master database, the changes will be replicated directly on to the slave database.

 

For more detailed information, do refer to the following link.

https://www.digitalocean.com/community/tutorials/5-common-server-setups-for-your-web-application

Why you should work at a cafe

Working at cafes is a common sight at countries like New York. So why should you work at a cafe in Singapore?

Different environment all the time

IMG_8028

Working at a cafe guarantees a different environment 90% of the time. For example, you can choose to head over to your favourite Starbucks outlet and spend your day there or you can choose to work at Coffee Bean.

Creating opportunities

IMG_5746

Did you know that working at cafes is actually creating opportunities for yourself? Because your potential clients could be anyone in the world, and like wise everyone that walks past or dine in the cafe you are at, are your potential clients as well. Personally, I have met a couple of clients just by working at cafes. So what are you waiting for?