3. Quest - Diffrence between MysqlDump and Mysqlhotcopy
Answr -
mysqlhotcopy- A Perl script uses LOCK TABLES, FLUSH TABLES, and cp or scp to make a database backup quickly.
It is the fastest way to make a backup of the database or single tables, but it can be run only on the same machine where the database directories are located.
mysqlhotcopy works only for backing up MyISAM and ARCHIVE tables. It runs on UNIX and NetWare
mysqldump - It can be used to dump a database or a collection of databases for backup or transfer to another SQL server (not necessarily a MySQL server).
The dump typically contains SQL statements to create the table, populate it, or both.
However, mysqldump can also be used to generate files in CSV, other delimited text, or XML format.
4. Quest - What is longblob data type in MySql?
Answr - Blob is Binary Large Object, used to store the image files or any files as a binary object in the table
5. Quest - What are the advantages of MyISAM over InnoDB?
Answr - MyISAM is a conservative approach to disk space management.
Each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed.
With InnoDB the tables are stored in tablespace, and not much further optimization is possible.
All data except for TEXT and BLOB can occupy 8,000 bytes at most.
No full text indexing is available for InnoDB. The COUNT(*)s execute slower than in MyISAM due to tablespace complexity.
6. Quest - What are HEAP tables in MySQL?
Answr - HEAP tables are in-memory. They are usually used for high-speed temporary storage.
No TEXT or BLOB fields are allowed within HEAP tables.
We can only use the comparison operators = and <=>.
HEAP tables do not support AUTO_INCREMENT.
Indexes must be NOT NULL.
7. Quest - How to get the current date?
Answr - Many ways curdate() OR current_date()OR now()
8. Quest- How to start MySQL on Linux?
Answr-
/etc/init.d/mysql start OR
service mysqld start/stop in RH
9. Quest - How to restore deleted records from mysql binary log file?
Answr -mysqlbinlog can be used to retrieve the sql transactions
How to use nexus MAVEN repository or local maven repository
Check inside your .m2 folder settings.xml, if not present then create one
Based on your build profile define the activeprofile name and provide the nexus/repo server name.
Check out parent repository which has all the sub repository stored in its meta file. (http://YourMavenNexusServer:port/repository/.meta/repository-metadata.xml
Use these information to create your maven settings/configuration.
for example:
TABLE test1
Name Null? Type
—————————————– ——– —————————-
A NOT NULL NUMBER(2)
B VARCHAR2(2)
C VARCHAR2(2)
D VARCHAR2(2)
E VARCHAR2(2)
Table test1 having 6 rows
set serverout on;
CREATE OR REPLACE PROCEDURE test5
IS
a number(2);
b VARCHAR2(2);
c VARCHAR2(2);
d VARCHAR2(2);
e VARCHAR2(2);
CURSOR cur IS
SELECT a as a , b as b ,c as c , d as d ,e as e from test1;
BEGIN
OPEN cur;
LOOP
FETCH cur INTO a,b,c,d,e;
EXIT WHEN cur%NOTFOUND;
dbms_output.put_line(a || b || c||d ||e);
END LOOP;
CLOSE CUR;
END;
/
====================================
set serverout on;
exec test5
To install sysstat or sar on debian/ubuntu use apt-get to install this
apt-get install sysstat
After this edit the configuration file
vi /etc/default/sysstat
change sadc option from false to true ENABLED=”true”
/etc/default/sysstat will look like #
# Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat
# and /etc/cron.daily/sysstat files
#
# Should sadc collect system activity informations? Valid values
# are “true” and “false”. Please do not put other values, they
# will be overwritten by debconf!
ENABLED=”true”
# Additional options passed to sa1 by /etc/init.d/sysstat
# and /etc/cron.d/sysstat
# By default contains the `-d’ option responsible for
# generating disk statisitcs.
SA1_OPTIONS=”-d”
# Additional options passed to sa2 by /etc/cron.daily/sysstat.
SA2_OPTIONS=”"
Restart the service sysstat service /etc/init.d/sysstat restart
Install the crontab
Then run crontab -e and add the following to collect stats: # Collect measurements at intervals
0 8-18 * * 1-5 /usr/lib/sysstat/sa1 1200 3 &
# Create daily reports and purge old files
5 19 * * 1-5 /usr/lib/sysstat/sa2 -A &
It is very essential and useful to put the login message in server’s login console to display the login message to avoid any unauthorised access to the system.
edit /etc/motd file
vi /etc/motd
Place the below text and save it ++++++++++++++++++++++++++++++++++++++++++++++
+ This is a private server!!! All ssh login attempts are logged and +
+ monitored by our staff. All unauthorized login attempts will be +
+ investigated and reported to local authorities. +
+ If you have any login problem please contact helpdesk +
++++++++++++++++++++++++++++++++++++++++++++++
Open another login console and try to login to the system, you will see this message.
If you get the following error while performing db import or any other activity on your mysql db
Mysql server gone away
You should try increasing wait_timeout to a greater value.
Most common reason for this error is due to server timing out and closing the connection there by generating following error codes CR_SERVER_LOST , CR_SERVER_GONE_ERROR .