[svc][db]mysql日常維護語句

來源:互聯網
上載者:User

標籤:ges   local   mat   null   har   查看命令   結構   多執行個體   show   

mysql啟動
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
建庫-建表-插資料
create database bbs;create table student(id int,name varchar(40));show create create table student;desc student;insert into student values(1,'maotai');
查看命令協助
MySQL [(none)]> help create
查表結構
- 查看錶結構(MySQL [bbs]> help show grants)可以看到文法MySQL [bbs]> show create table student;+---------+------------------------------------------------------------------------------------------------------------------------------+| Table   | Create Table                                                                                                                 |+---------+------------------------------------------------------------------------------------------------------------------------------+| student | CREATE TABLE `student` (  `id` int(11) DEFAULT NULL,  `name` varchar(44) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 |+---------+------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)- 查看錶結構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)
更新使用者密碼
## 更改mysql密碼: mysqladmin- 為root設定密碼mysqladmin -uroot password 12345678- 為root修改密碼(已有密碼)$ mysqladmin -uroot -p123456 password 12345678Warning: Using a password on the command line interface can be insecure.- 為root修改密碼(多執行個體)$ mysqladmin -uroot -p123456 password 12345678 -S /data/3306/mysql.sock## 更改密碼: update語句- 查看錶欄位MySQL [(none)]> desc mysql.user- 查看使用者MySQL [(none)]> select user,host,password from mysql.user;- 修改密碼(明文: 這樣是錯誤的)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 from mysql.user;+------+------+----------+| user | host | password |+------+------+----------+| root | %    | 123456   |+------+------+----------+1 row in set (0.00 sec)- 正確的姿勢MySQL [(none)]> update mysql.user set password=password('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)小結:1,帶where條件2,指定password()函數## set- 適合改密碼情境MySQL [(none)]> set password=password('maotai');Query OK, 0 rows affected (0.00 sec)

[svc][db]mysql日常維護語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.