Mysql

Mysql

 

mysql command line access

mysql -u root -p

Import and Export table

mysqldump -u root -p dev_vclub member_routesfares > member_routesfares_dev.txt
mysql -u root -p demo_vclub_sprint4 < member_routesfares_dev.txt

http://www.tutorialspoint.com/mysql/mysql-database-export.htm

Transfer to other host

tar -cvf demo_vclub_sprint4.tar demo_vclub_sprint4.sql
wget http://api.wolfkrow.com/demo_vclub_sprint4.tar

http://www.digimantra.com/technology/mysql/transfer-database-host-mysqldump-shell/

Split function

CREATE FUNCTION SPLIT_STR(
x VARCHAR(255),
delim VARCHAR(12),
pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
delim, ”);

http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/

Edit Bind-address

http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

Edit /etc/mysql/my.cnf, run:
bind-address

Grant privllage

for accessing other host mysql

GRANT ALL ON demo_vclub_sprint6.* TO root@’200.53.158.25′ IDENTIFIED BY ‘notouch’

Rename Database

mysqldump -u root -p -v olddatabase > olddbdump.sql
mysqladmin -u root -p create vclub
mysql -u root -p vclub < olddbdump.sql

http://stackoverflow.com/questions/67093/how-do-i-quickly-rename-a-mysql-database-change-schema-name

Replace into

 

Please note that REPLACE INTO is a much slower performer than an UPDATE statement. Keep in mind that a REPLACE INTO requires a test on the keys, and if a matching unique key is found on any or all columns, a DELETE FROM is executed, then an INSERT is executed. There’s a lot of management of rows involved in this, and if you’re doing it frequently, you’ll hurt your performance unless you simply cannot do with any other syntax.

The only time when I can see where you’d actually need a REPLACE INTO is when you have multiple unique constraints on a table, and need to drop any rows that would match any of the constraints. Then REPLACE INTO becomes more efficient from DELETE FROM… INSERT INTO…

http://www.webs05.com/2008/04/06/mysql-difference-between-update-and-replace.html

INSERT INTO user (userid,birthday,first_name,last_name)
VALUES (1234,’1980-03-07′,’Joe’,’Smith’)
ON DUPLICATE KEY UPDATE
birthday = ‘1980-03-07’,
first_name = ‘Joe’,
last_name = ‘Smith’;

http://stackoverflow.com/questions/2930378/mysql-replace-into-alternative

Replication

http://www.howtoforge.com/mysql_database_replication_p2

Advertisements

About rahul23134654

Hi, I am Rahul Meha , B.E. in (I.T.)
This entry was posted in Mysql. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s