Telegram Group & Telegram Channel
MySQL

Auto insert with TimeStamp
CREATE TABLE test (
id INTEGER,
txt VARCHAR(20),
ts1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

Copy Database
mysqldump -u root -p db1 > dump.sql
mysqladmin -u root -p create db2
mysql -u root -p db2 < dump.sql


Create User
mysql> grant all privileges on DBNAME.* to USERNAME@localhost identified by 'PASSWORD';
mysql> grant all privileges on DBNAME.* to USERNAME@"%" identified by 'PASSWORD';
mysql> flush privileges;


--all DB
mysql> grant all privileges on *.* to USERNAME@localhost identified by 'PASSWORD';
mysql> grant all privileges on *.* to USERNAME@"%" identified by 'PASSWORD';
mysql> flush privileges;


Delete User
mysql> drop user USERNAME;
or
mysql> delete from mysql.user where user = 'USERNAME';


Change Password
--User
mysql> set password for USER@"%" = password('PASSWORD');
mysql> set password for USER@localhost = password('PASSWORD');


--root
mysql> set password for root=password('PASSWORD');
mysql> set password for root@localhost=password('PASSWORD');

CSV Import / Export
ERROR 1045 (28000) at line 1: Access denied for user 'USER'@'localhost' (using password: YES)
mysql> grant file on *.* to USER@localhost;


Tips
--Create table as same data and type
mysql> create table newtable as select * from orgtable;


--Create table with same type. data is null.
mysql> create table newtable as select * from orgtable where id is null;

Export to CSV
# mysql -uUSER -pPASS DATABASE -e "select * from TABLE;" | sed -e 's/^/"/g' | sed -e 's/$/"/g' | sed -e 's/\t/","/g' > /tmp/test.csv



tg-me.com/linux_srv/460
Create:
Last Update:

MySQL

Auto insert with TimeStamp
CREATE TABLE test (
id INTEGER,
txt VARCHAR(20),
ts1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

Copy Database
mysqldump -u root -p db1 > dump.sql
mysqladmin -u root -p create db2
mysql -u root -p db2 < dump.sql


Create User
mysql> grant all privileges on DBNAME.* to USERNAME@localhost identified by 'PASSWORD';
mysql> grant all privileges on DBNAME.* to USERNAME@"%" identified by 'PASSWORD';
mysql> flush privileges;


--all DB
mysql> grant all privileges on *.* to USERNAME@localhost identified by 'PASSWORD';
mysql> grant all privileges on *.* to USERNAME@"%" identified by 'PASSWORD';
mysql> flush privileges;


Delete User
mysql> drop user USERNAME;
or
mysql> delete from mysql.user where user = 'USERNAME';


Change Password
--User
mysql> set password for USER@"%" = password('PASSWORD');
mysql> set password for USER@localhost = password('PASSWORD');


--root
mysql> set password for root=password('PASSWORD');
mysql> set password for root@localhost=password('PASSWORD');

CSV Import / Export
ERROR 1045 (28000) at line 1: Access denied for user 'USER'@'localhost' (using password: YES)
mysql> grant file on *.* to USER@localhost;


Tips
--Create table as same data and type
mysql> create table newtable as select * from orgtable;


--Create table with same type. data is null.
mysql> create table newtable as select * from orgtable where id is null;

Export to CSV
# mysql -uUSER -pPASS DATABASE -e "select * from TABLE;" | sed -e 's/^/"/g' | sed -e 's/$/"/g' | sed -e 's/\t/","/g' > /tmp/test.csv

BY Типичный Сисадмин


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/linux_srv/460

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

The lead from Wall Street offers little clarity as the major averages opened lower on Friday and then bounced back and forth across the unchanged line, finally finishing mixed and little changed.The Dow added 33.18 points or 0.10 percent to finish at 34,798.00, while the NASDAQ eased 4.54 points or 0.03 percent to close at 15,047.70 and the S&P 500 rose 6.50 points or 0.15 percent to end at 4,455.48. For the week, the Dow rose 0.6 percent, the NASDAQ added 0.1 percent and the S&P gained 0.5 percent.The lackluster performance on Wall Street came on uncertainty about the outlook for the markets following recent volatility.

The Singapore stock market has alternated between positive and negative finishes through the last five trading days since the end of the two-day winning streak in which it had added more than a dozen points or 0.4 percent. The Straits Times Index now sits just above the 3,060-point plateau and it's likely to see a narrow trading range on Monday.

telegram from sg


Telegram Типичный Сисадмин
FROM USA