[Svc] [Db]mysql Daily Maintenance statements

Source: Internet
Author: User
Tags docker run

MySQL Boot
docker run  -p 3306:3306 -v /data/mysql:/var/lib/mysql -v /etc/localtime:/etc/localtime --name mysql5 --restart=always -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6.23 --character-set-server=utf8 --collation-server=utf8_general_ci
Build Library-Build table-interpolate data
create database bbs;create table student(id int,name varchar(40));show create create table student;desc student;insert into student values(1,'maotai');
View command Help
MySQL [(none)]> help create
Check table structure
-View table structure (MySQL [bbs]> help show grants) can see syntax MySQL [bbs]> show create table student;+---------+-------------------- ----------------------------------------------------------------------------------------------------------+| Table |                                                                                                                 Create Table |+---------+--------------------------------------------------------------------------------------------------- ---------------------------+| Student | CREATE TABLE ' student ' (' ID ' int (one) default null, ' name ' varchar () default null) ENGINE=INNODB default Charset=utf8 |+---------+--------------------------------------------------------------------------------------------------- ---------------------------+1 Row in Set (0.00 sec)-View table structure MySQL [bbs]> desc student;+-------+-------------+------+-- ---+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+-------+| ID | Int (11) |     YES | |       NULL | || name | varchar (44) |     YES | |       NULL | |+-------+-------------+------+-----+---------+-------+2 rows in Set (0.02 sec)
Update user Password
# # change MySQL password: mysqladmin-password for root mysqladmin-uroot password 12345678-change password for root (existing password) $ mysqladmin-uroot-p123456 PASSW Ord 12345678warning:using a password on the command line interface can be insecure.-for root change password (multi-instance) $ mysqladmin-uroot-p 123456 password 12345678-s/data/3306/mysql.sock## Change Password: UPDATE statement-view table field MySQL [(none)]> desc mysql.user-View user MySQL [(n One)]> Select User,host,password from mysql.user;-Change Password (clear text: This is wrong) MySQL [(none)]> update mysql.user set password= ' 123456 ' where user= ' root ' and host= '% '; Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 Warnings:0mysql [(None)]> Select User,host,password fr Om mysql.user;+------+------+----------+| user | Host | Password |+------+------+----------+| Root | %    | 123456 |+------+------+----------+1 row in Set (0.00 sec)-Correct posture MySQL [(none)]> update Mysql.user set PASSWORD=PASSWO RD (' 123456 ') where user= ' root ' and host= '% '; Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 warnings:0mysqL [(None)]> flush privileges; Query OK, 0 rows affected (0.03 sec) Summary: 1, with where Condition 2, specify password () function # # set-suitable for changing the password scene MySQL [(none)]> set Password=password ( ' Maotai '); Query OK, 0 rows Affected (0.00 sec)

[svc][db]mysql Daily Maintenance statements

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.