Mysql常用操作

2021-09-02 01:15:41 字數 1098 閱讀 1526

mysql -h localhost -u root -proot

// 刪除資料庫

drop database aaa

// 建立資料庫 aaa

create database aaa default character set utf8 collate utf8_general_ci;

// 匯出資料庫

mysqldump -h localhost -u root -proot --opt -d bbb --default-character-set=utf8 > bbb.sql

mysqldump -h localhost -u root -proot bbb --default-character-set=utf8 > bbb.sql

// 匯入資料庫

mysql -h localhost -uroot -proot --default-character-set=utf8 ccc < ccc.sql

修改使用者密碼

alter user 'root'@'localhost' identified with mysql_native_password by '123456';

create user 'dbname'@'localhost' identified by '123456';

grant all on *.* to 'dbname'@'localhost'

mysql -u root mysql

update user set password=password('newpassword') where user='root';

flush privileges;//記得要這句話,否則如果關閉先前的終端,又會出現原來的錯誤

\q

select concat( 'drop table ', table_name, ';' ) 

from information_schema.tables

where table_name like 'ts_blog%' and table_schema='sxpt_info';

my sql常用操作

1.grant allprivilegeson tomonty localhost identified by something with grant option monty 可以從任何地方連線伺服器的乙個完全的超級使用者,但是必須使用乙個口令 something 做這個。注意,我們必須對 mo...

mysql 常用操作

1 修改表名在mysql中修改表名的sql語句在使用mysql時,經常遇到表名不符合規範或標準,但是表裡已經有大量的資料了,如何保留資料,只更改表名呢?alter table table name rename to new table name 例如alter table admin user r...

mysql常用操作

mysql常用操作 修改root密碼 用root 進入mysql後 mysql set password password 你的密碼 mysql flush privileges 檢視表結構 show create table 表名 清空表且令自增字段從1開始 truncate table 表名 檢...