|
MySQL AB :: MySQL 3.23, 4.0, 4.1 Reference Manual :: 12.2.4.1 INSERT ... SELECT Syntax
dev.mysql.com/doc/refman/4.1/en/insert-select.html 12.2.4.1. |
| Employee.LastName | Employee.DepartmentID | Department.DepartmentName | Department.DepartmentID |
|---|---|---|---|
| Smith | 34 | Clerical | 34 |
| Jones | 33 | Engineering | 33 |
| Robinson | 34 | Clerical | 34 |
| Steinberg | 33 | Engineering | 33 |
| Rafferty | 31 | Sales | 31 |
MySQL supports incremental backups: You need to start the server
with the --log-bin option to enable binary
logging; see Section 5.10.3, “The Binary Log”. At the moment you
want to make an incremental backup (containing all changes that
happened since the last full or incremental backup), you should
rotate the binary log by using FLUSH LOGS.
This done, you need to copy to the backup location all binary
logs which range from the one of the moment of the last full or
incremental backup to the last but one. These binary logs are
the incremental backup; at restore time, you apply them as
explained further below. The next time you do a full backup, you
should also rotate the binary log using FLUSH
LOGS, mysqldump --flush-logs, or
mysqlhotcopy --flushlog. See
Section 7.13, “mysqldump — A Database Backup Program”, and Section 7.14, “mysqlhotcopy — A Database Backup Program”.
If your MySQL server is a slave replication server, then
regardless of the backup method you choose, you should also back
up the master.info and
relay-log.info files when you back up your
slave's data. These files are always needed to resume
replication after you restore the slave's data. If your slave is
subject to replicating LOAD DATA INFILE
commands, you should also back up any
SQL_LOAD-* files that may exist in the
directory specified by the --slave-load-tmpdir
option. (This location defaults to the value of the
tmpdir variable if not specified.) The slave
needs these files to resume replication of any interrupted
LOAD DATA INFILE operations.
[mysql dir]/bin/mysql -h hostname -u root -p
create database [databasename];
show databases;
use [db name];
show tables;
describe [table name];
drop database [database name];
drop table [table name];
SELECT * FROM [table name];
show columns from [table name];
SELECT * FROM [table name] WHERE [field name] = "whatever";
SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;
SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';
SELECT * FROM [table name] WHERE rec RLIKE "^a$";
SELECT DISTINCT [column name] FROM [table name];
SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
SELECT COUNT(*) FROM [table name];
SELECT SUM(*) FROM [table name];
select lookup.illustrationid, lookup.personid,person.birthday from lookup
left join person on
lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
INSERT INTO [table name] (Host,User,Password) VALUES('%','user',PASSWORD('password'));
[mysql dir]/bin/mysqladmin -u root -h hostname.blah.org -p password 'new-password'
SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
grant usage on *.* to bob@localhost identified by 'passwd';
INSERT INTO [table name] (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES
('%','databasename','username','Y','Y','Y','Y','Y','N');
or
grant all privileges on databasename.* to username@localhost;
UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
DELETE from [table name] where [field name] = 'whatever';
FLUSH PRIVILEGES;
alter table [table name] drop column [column name];
alter table [table name] add column [new column name] varchar (20);
alter table [table name] change [old column name] [new column name] varchar (50);
alter table [table name] add unique ([column name]);
alter table [table name] modify [column name] VARCHAR(3);
alter table [table name] drop index [colmn name];
LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
[mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
[mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
[mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
[mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql
[root@host root]#killall mysqld [root@host root]#/usr/libexec/mysqld -Sg --user=root & |
mysqld --skip-grant-tables --user=root |
Set the default character set:
mysql --default-character-set=utf8
mysql> SHOW VARIABLES LIKE 'char%';mysql> GRANTpriv_type[(column_list)] [,priv_type[(column_list)]] ...
ON [object_type] {tbl_name| * | *.* |db_name.*}
TOuser[IDENTIFIED BY [PASSWORD] 'password']
[,user[IDENTIFIED BY [PASSWORD] 'password']] ...
[REQUIRE
NONE |
[{SSL| X509}]
[CIPHER 'cipher' [AND]]
[ISSUER 'issuer' [AND]]
[SUBJECT 'subject']]
[WITHwith_option[with_option] ...];
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ian'@'192.168.1.11'
IDENTIFIED BY 'mypassword'
WITH GRANT OPTION;