Mysql

How to grant privileges in mysql

Grant only select in mysql

To grant privileges in mysql first, it is must to know what permission has to be provided to the user, about his requirement and who is he for the application. Then you can provide required permission for the user. The prompt should now look like this: # mysql -u admin -p  ..

How to list find all mysql users

List all MySQL Users via Query

How do I list all mysql user present in a mysql server? # Select User FROM mysql.user The above query will only display mysql users present on the server. # Select TRIM(User) AS username FROM mysql.user Mysql user can be selected as above, by using select query  ..

Mysql remove new line using select

Mysql cut or trim new line select query

# SELECT TRIM(name) AS name FROM your_table Syntax for trim function # TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str) Trim new line of specified field # select * from tablename where TRIM(BOTH '\r' from (TRIM(BOTH '\n' from filedname))) = '$value' where, LTRIM() = Removes leading spaces RTRIM() = Removes  ..

Grand permission for a mysql user

How to fix Access Denied for mysql user

If you get a permission error while accessing MySQL Database? Use the following sql command to fix privilege issues. # GRANT ALL ON database_name TO 'user_name'@'localhost'; # FLUSH PRIVILEGES; First you have to provide access for a user to specific database once you have made permission changes, it's good  ..

Create mysql table from query info

Create mysql table from query info

A new mysql table can be created with the information what we fetch from from select query, Below example will provide you the details for creating a new mysql table by using the select query. Herw you fetch the table info and create a new table by using the  ..

Dump sql table from specified value

Dump Particular range of values from table in Sql

Normally we would have dumped entire mysql table whenever required, sometime we might have a need to take a backup or copy the specified range of vales from one mysql table to other using table, In such case here is simple sql to dump particular range of values into a  ..

How to filter valid emails from database

How to search valid emails from mysql database

There are other methods to find whether a mail-id is a valid mail id or not. It is always better to make the check and add mail id into database, but however if you can filter the valid email ids from below mysql query Mysql query to filter emails from database   ..

How to sum two intervals

How to sum two intervals in mysql

By using case statement in mysql you can pass the conditions to get sum of different intervals Finding sum of difference between two intervals select name,email,uid, sum(case when (paymentDate between \'2012-12-01\' and \'2013-06-06\') then paid else 0 end) paid1, sum(case when (paymentDate between \'2011-12-01\' and \'2012-06-06\') then paid else 0 end) paid2 from transaction,user where  ..

How to add mysqldump in cron

Mysql dump scheduler

I have set the below scheduler in our local environment to take backup of our staging Linux server. The cron job is set in our Linux environment. In order to add cron job for database using mysqldump use the following line, * * * * * mysqldump -h hostname -u root  ..

How to fix mysql slow connection

Mysql Sleep Connection

How to fix mysql slow connection? Most of would have faced MySQL slow connection issue, it might be because of improper configuration or bad queries we use. The best way of coding will be to make a check and close MySQL connection properly. MySQL: show processlist; Where, you might find too many  ..

Sort records from given date

Sort records from current day

Mysql automation- Sort Records from today Key 1:This idea is most usefull to sort records based on ascending sequence from current day. Key 2:Sort Records from today select ,month(future_date) as nmonth from where if(month(future_date)=MONTH(CURDATE()),day(future_date)>DAY(CURDATE()),day(future_date)>0) ORDER BY CASE WHEN month(future_date) >= month(date_add(current_date, interval 0 month)) THEN 0 else 1 END, CASE WHEN  ..

How to multiply zero n non zero columns

Multiply zero and non zero columns in mysql

How to multiply zero and non zero columns in mysql? If the quantity field is less than '1', then its value is considered as(quantity= 1) SELECT itemname,amount,quantity,(amount*(CASE WHEN quantity <=0 THEN 1 ELSE quantity END ) ) as total from your_tablename itemname | amount | quantity |  ..

How to add comments on table field name

Adding comments to mysql filename

You would have experience adding comments on a program or on script. But you can also add comment to a mysql field is as below alter table table_name change column_name field_name tinyint(3) 'your comment on this field'; This will help you to add comment on the files.  ..

How to restore mysql database from frm files

Xampp restore mysql database from frm format

Many time when you use xampp, you will be having a qustion on restoring mysql database from you can restore mysql databases from .frm file. You can follow the below steps to restore the database. 1) Copy your database folders from the data folder("C:\\xampp\mysql\data") 2) Paste the database into your new xampp  ..

Error 121203 reading the header from binary log

Error 121010 failed to open log

When trying to start mysql ,i got the following error : 121203 14:20:43 [ERROR] I/O error reading the header from the binary log, errno=-1, io cache code=0 121203 14:20:43 [ERROR] I/O error reading the header from the binary log 121203 14:20:43 [ERROR] Can't init tc log 121203 14:20:43 [ERROR] Aborting 121010 13:57:47 [ERROR] I/O error  ..

1 2 3 Next

Tech Bluff