MYSQL:The preparatory work

0.start
--mysqld
--sudo service mysql restart

1.mysql character
1.1.my.ini
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8

--2.chg pwd
--2.1.chg pwd
mysqladmin -uroot -p"" password 123456
--2.2.chg pwd
mysql -uroot
mysql> use mysql;
mysql> update user set password=password(‘123456‘) where user=‘root‘ and host=‘localhost‘;
mysql> set password for root@localhost = password(‘123456‘);
mysql> flush privileges;

--2.3when forget password
mysqld --skip-grant-tables

mysql
mysql> use mysql;
mysql> update user set password=password(‘123‘) where user=‘root‘ and host=‘localhost‘;
mysql> flush privileges;

--3.query character
mysql> show variables like ‘character%‘;
mysql> show variables like ‘collation% ‘;
--only avalable for current connection
--set names gbk
--character_set_client,character_set_connection,character_set_results



--4.database
mysql> show databases;
mysql> drop database test;
mysql> create database if not exists test default character set utf8;
mysql> select database();

--5.create user
mysql> select user();
mysql> create user user01@‘localhost‘ identified by ‘123456‘;
mysql> create user user02@‘%‘ identified by ‘123456‘;
mysql> drop user user02;

--6.grant privileges
mysql> grant all privileges on test.* to user01;
mysql> show grants for user01;
mysql> revoke select on *.* from ‘test‘@‘%‘;


--7.tables
mysql> show tables;
mysql> CREATE TABLE user(
    `id` int not null default 0 primary key,
    `name` varchar(50) default ‘ananimous‘,
    `age` int not null default 0,
    `password` varchar(50),
    `create_time` datetime not null default ‘2008-01-01 00:00:00‘,
     key `create_time`(`create_time`)
);

--8.index
mysql> show index from user;
mysql> alter table `user` add index idx_age(`age`);
 

--9.insert
mysql> insert user(id, name, age, password, create_time) values(100,‘zs‘,20,‘1234‘, ‘2021-10-10 11:11:20‘);
mysql> select * from user;

--10.exit
mysql>quit

MYSQL:The preparatory work

上一篇:Photoshop 有艺术感觉的立体效果的胶片边框


下一篇:《Webpack实战》学习总结