What are the basic commands that MySQL must have
Below I will give you a brief talk about what MySQL must know the basic commands, you know before the related similar topic content? If you are interested, take a look at this article together. I believe that after reading which MySQL basic commands will be helpful to everyone.
1.1 Log in to the database.
mysql -uroot -poldboy123 -S /data/3306/mysql.sock
1.2 View the database version and what the current logged-in user is.
select version();select user();
1.3 Create a database oldboy of GBK character sets and view the complete statements of the library.
create database oldboy character set gbk collate gbk_chinese_ci;show create database oldboy\G
1.4 Create user oldboy to manage database oldboy.
grant all on oldboy.* to 'oldboy'@'localhost' identified by 'oldboy123';
1.5 See what permissions the created user oldboy has.
show grants for oldboy@localhost\G
1.6 See which users are currently in the database.
select user,host from mysql.user;
1.7 Create admin account admin
grant all on *.* to 'admin'@'localhost' identified by 'admin123' with grant option;
1.8 Enter the oldboy database
use oldboy;
1.9 Create test table: innodb engine, character set GBK, field id int(4) and name varchar(16), view table structure and SQL statement.
create table test (id int(4),name varchar(16))ENGINE=innodb DEFAULT CHARSET=gbk;desc test; #1;
1.13 Change the name oldboy with data id equal to 1 to oldgirl.
update test set name='oldgirl' where id=1;
1.14 Insert an age field of type tinyint(2) before the field name.
alter table test add name tinyint(2) after id;
1.15 Backup oldboy and mysql libraries.
mysqldump -uroot -poldboy123 -S /data/3306/mysql.sock --events -B oldboy mysql >/opt/bak_$(date +%F).sql
egrep -v "#|^$|--|\/" /opt/bak_2017-06-06-13:36:37.sql
1.16 Delete all data from the table and view it.
truncate table test; #