host is not allowed to connect to this mysql server

one of the most conman error when connecting to MySQL server is “host is not allowed to connect to this MySQL server” this because of the user don’t have right privileges to connect to this MySQL server follow below steps to connection issue in MySQL

if you have full permission in MySQL

Open Mysq-> phpmyadmin

Go to User accounts section

Create a new user and give all the privilege as shown in the below image

host is not allowed to connect to this mysql server

if you have cpanel info

Go to MySQL® Databases section

Scroll down to Add New User section

host is not allowed to connect to this mysql server 2

After Scroll down to Add User To Database section

Select table and user and Add User To Database

Click all ALL PRIVILEGES and Make Changes

host is not allowed to connect to this mysql server 3

Select all data from MySQL where date between two given dates

Here is the simple MySQL query to fetch data between given date range

See MySQL query



$f_date=$_REQUEST['f_date'];

$t_date=$_REQUEST['t_date'];

"SELECT * FROM sales WHERE  sales_invoice_date between '".date('Y-m-d',strtotime($f_date))."' and '".date('Y-m-d',strtotime($t_date))."' "

To Fetch all the sales data in the given date

"SELECT * FROM sales WHERE sales_invoice_date='".date('Y-m-d',strtotime($f_date))."'" 

To fetch Today’s Sales

SELECT * FROM sales WHERE STR_TO_DATE(sales_invoice_date , '%d-%m-%Y') = CURDATE()

Full Text Search In MySQL ,a better way for MySQL Text search

One of the most common issue with MySQL is searching for a matching string from a huge database,suppose we need to search for ‘MySQL Tutorial’ it will only search the occurrence of ‘MySQL Tutorial’ neither ‘MySQL’ or ‘Tutorial’ also in MySQL compared to INT value search Char/Text is time consuming to solve this issue, we have Full Text Search .Full Text Search is a technique used by search engine to find the results in a database.we can use Full Text search in search Query.First you must create a full-text index on the table before you run full-text queries on a table.

Creating a full-text index inside a Table

ALTER TABLE TABLE NAME ADD FULLTEXT (FIELD1, FIELD2,FIELD3, etc)

Example

ALTER TABLE wptt_posts ADD FULLTEXT (`post_title`, `post_content`)

Full Text Search In MySQL

Now we created Full Text Index in wptt_posts table,next we will discuss how to use Full Text Search in MySQL


MySQL Query Using Full Text Search

SELECT * FROM TABLE NAME WHERE MATCH (FILED1FILED2,FILED3) AGAINST ('SEARCH WORD' IN NATURAL LANGUAGE MODE)

Example

SELECT * FROM wptt_posts WHERE MATCH (post_title,post_content) AGAINST ('Mysql Tutorials' IN NATURAL LANGUAGE MODE)
Full Text Search In MySQL 2

We can use the match case based on the Score

SELECT MATCH (post_title,post_content) AGAINST ('Mysql Tutorials') as score, post_title FROM wptt_posts WHERE MATCH (post_title,post_content) AGAINST ('Mysql Tutorials' IN NATURAL LANGUAGE MODE)



Full Text Search In MySQL 3

Where the score value represent the occurrence of search term in the filed

We can skip words (exclude words) from the result

For e.g “-Tutorials” means the search result should not contain Tutorials

SELECT * FROM wptt_posts WHERE MATCH (post_title,post_content) AGAINST ('+Mysql -Tutorials' IN BOOLEAN MODE)


update query in mysql with example

MySQL is an open-source relational database management system,actually the name MySQL come from the combinations of words “My“(name of co-founder Michael Widenius’s daughter) and “SQL“(Structured Query Language).Since MySQL is free and open-source it is the most popular and huge used RDBMS. In this section we are going to check out how to write a update query in MySQL.Let me explain the syntax for update query in mysql with example

Syntax

"UPDATE `TABLE_NAME` SET `COLUMN_NAME` = `VALUE' WHERE  [condition];

Example

"UPDATE student  SET mobile ='9999999999' WHERE id='9'";

update query in mysql