Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

FAQ
It is currently Sat Nov 18, 2017 4:16 pm


News News of Mysql

Site map of Mysql » Forum : Mysql

Mysql Application & Query Optimization, Questions, Indexes, Bugs.

 [ Total topics 21 Go to page 1, 2, 3

Message
 Post subject: Mysql change root password
PostPosted: Tue Feb 10, 2015 6:50 pm 
Mysql administrator account is the "root" account. As in Linux this account has all privileges, writing and reading all the databases in MySql server, changing running parameters of the server and so on. It is a security safeguard to keep this password as long and complex as possible (to include upper and lower characters, digits and SHIFT+Numerical keys.

Changing MySql root account password:


To change mysql root password, use administrator account, usually root, and run ...

Read more : Mysql change root password | Views : 1073 | Replies : 0

Top
 Post subject: Mysql drop (remove) unique key
PostPosted: Wed Jan 14, 2015 7:53 pm 
To remove a mysql unique key, aka index it first needs to be checked.

How to check mysql unique indexes existing on a table:

mysql> SHOW INDEXES FROM my_table;
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| my_table | 0 | id | 1 | id | A | 0 | NULL ...

Read more : Mysql drop (remove) unique key | Views : 972 | Replies : 0

Top
 Post subject: Mysql convert unix timestamp to human readable format
PostPosted: Wed Jan 14, 2015 11:36 am 
Mysql and Unix timestamps are numerical values representing number of seconds elapsed since 1st of January 1970.

Mysql: How to get timestamp of current time:
Code:
mysql> select UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1421249658 |
+------------------+
1 row in set (0.00 sec)


Mysql: How to convert unix timestamp to human readable format:
Code:
mysql> select FROM_UNIXTIME(UNIX_TIMESTAMP());
+---------------------------------+
| FROM_UNIXTIME(UNIX_TIMESTAMP()) |
+---------------------------------+
| 2015-01-14 17:34:49             |
+---------------------------------+
1 row in set (0.00 sec)


Note ...

Read more : Mysql convert unix timestamp to human readable format | Views : 1703 | Replies : 0

Top
 Post subject: Mysql show stored procedures and functions
PostPosted: Mon Nov 18, 2013 9:06 am 
Following two commands show stored procedures and functions in a mysql database:
Code:
SHOW PROCEDURE STATUS;
SHOW FUNCTION STATUS;

Read more : Mysql show stored procedures and functions | Views : 1087 | Replies : 0

Top
 Post subject: How to calculate mysql time difference between unix timestamp column and now() format
PostPosted: Fri May 31, 2013 4:10 am 
Calculating the time difference between the following timestamp format mysql column and current time:

Code:
mysql> SELECT created_on FROM `account`;                   
+------------+
| created_on |
+------------+
| 1369986975 |
+------------+
1 row in set (0.00 sec)


Code:
mysql> SELECT TIME_TO_SEC(TIMEDIFF(NOW(), FROM_UNIXTIME(`created_on`))) AS `time_diff` FROM `account`;
+-----------+
| time_diff |
+-----------+
|       799 |
+-----------+
1 row in set (0.00 sec)


This calculates the difference in seconds between current time and unix timestamp column. Obviously, to turn this into ...

Read more : How to calculate mysql time difference between unix timestamp column and now() format | Views : 4838 | Replies : 0

Top
 Post subject: Getting Postgre SQL query output format equivalent to MySql \G
PostPosted: Wed Jun 13, 2012 7:31 am 
In order to format Postgre SQL query output similar to MySql \G, expanded display needs to be turned on:

Code:
# \x
Expanded display is on.
# SELECT * FROM my_table;
-[ RECORD 1 ]------------------------+--------------------------------------------
id                                     | 2
start_time                             | 3452345345
partner_id                             | 3
location_id                            | 4
severity                               | 1


Read more : Getting Postgre SQL query output format equivalent to MySql \G | Views : 766 | Replies : 0

Top
 Post subject: Mysql> how to store select Zulu / UTC timestamp in database
PostPosted: Fri Dec 16, 2011 5:23 am 
To obtain/store the current time in mysql, function "NOW()" needs to be used. But this takes into consideration the timezone set on the server.

To store the UTC time, in the same format, "UTC_TIMESTAMP()" function can be used:

mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2011-12-16 10:19:33 |
+---------------------+
1 row in set (0.00 sec)

mysql> select UTC_TIMESTAMP();
+---------------------+
| UTC_TIMESTAMP() |
+---------------------+
| 2011-12-16 09:19:36 |
+---------------------+
1 row in set (0.05 ...

Read more : Mysql> how to store select Zulu / UTC timestamp in database | Views : 584 | Replies : 0

Top
 Post subject: Mysql> stored procedure for inserting in multiple tables \w common key
PostPosted: Tue Nov 22, 2011 5:15 pm 
Below is an example of a mysql stored procedure that:
1) drops the procedure if it already exists
2) creates procedure and defines the fields that it accepts
3) declares an internal variable
4) inserts a row in multiple tables having a common key all tables using last_insert_id() from the first table as their first column's value
5) sets the internal variable to the last_insert_id()
6) selects the internal variable, returning it to the calling ...

Read more : Mysql> stored procedure for inserting in multiple tables \w common key | Views : 2982 | Replies : 1

Top
 Post subject: Mysql> select records that have date/datetime column equal to today's date
PostPosted: Tue Nov 22, 2011 9:40 am 
How to select rows from a mysql table containing multiple records, all of them having a datetime column.

Example mysql table:
Code:
mysql> select * from info;
+---------+---------------------+------------+
| id | upload_date    | ip    |
+---------+---------------------+------------+
|       1 | 2011-11-21 21:07:29 | 0123456789 |
|       2 | 2011-11-21 21:15:07 | 0123456789 |
|       3 | 2011-11-22 14:26:49 | 0123456789 |
+---------+---------------------+------------+
3 rows in set (0.00 sec)


Selecting rows with datetime column equal to today's ...

Read more : Mysql> select records that have date/datetime column equal to today's date | Views : 1844 | Replies : 0

Top
 Post subject: How to use a mysql stored procedure
PostPosted: Mon Nov 21, 2011 4:12 pm 
Unlike other sql commands, stored procedures need to be called. Therefore the CALL command needs to be used:

Code:
mysql> CALL stored_procedure_name('argument1,'argument2');

Read more : How to use a mysql stored procedure | Views : 628 | Replies : 1

Top
 [ Total topics 21 Go to page 1, 2, 3


Last 10 active topics


Shell Scripting and Programming

No new posts BASH shell script to mointor a directory and move file without overwriting destination
View the latest post
No new posts FreeBSD: Install python package manager (pip)
View the latest post
No new posts Shell scripting
View the latest post

OpenLDAP - Lightweight Directory Access Protocol

No new posts Synchronize OpenLDAP and Microsoft Active Directory
View the latest post

Routing and dynamic routing protocols

No new posts BGP Notification Message (3), length: 21, OPEN Message Error (2), subcode Authentication Failure
View the latest post
No new posts JUNOS BGP: How to drain a BGP peering router gracefully without bgp session reset
View the latest post

TCP/IP Networking

No new posts Problem pinging and using server with mobile hotspot
View the latest post

Memory, Storage, Backup and Filesystems

No new posts FreeBSD: List disk drives and re-scan after adding hot-add disk (in virtual environments)
View the latest post

Apache, Nginx, Lighttpd and other web server software

No new posts NGINX: 413 Request Entity Too Large
View the latest post

System administration

No new posts MAC OS X: read image/jpeg EXIF information on command line
View the latest post

Login

Username:   Password:   Log me on automatically each visit  

Statistics

Statistics

Total posts 612 | Total topics 982 | Total members 1193



News News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list


Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]



phpBB SEO