mysql管理员操作
mysql查幫助手冊的技巧:help 你的命令;比如 help create;
>>顯示mysql中用戶:select host,user from mysql.user;
>>>創(chuàng)建用戶:mysql> create user 'zhangpeng'@'%' identified by 'oradt!@#&*(';
>>授權(quán)某個(gè)用戶擁有某個(gè)數(shù)據(jù)庫的任何權(quán)限:
GRANT ALL PRIVILEGES ON stock_info.* TO 'test'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
創(chuàng)建數(shù)據(jù)庫:?mysql> create database stock_info default charset utf8 collate utf8_general_ci;
>>> 查看用戶權(quán)限(顯示用戶權(quán)限): show grants from? 用戶名;? //show grants; 顯示當(dāng)前自己的權(quán)限
修改用戶密碼-> 首先進(jìn)入命令行下, 以root用戶登錄,命令:mysql -uroot -p 回車 輸入密碼再回車;
????????????? USER mysql;
????????????? UPADTE user set? password=password('root') where user='root';
?mysql> FLUSH PRIVILEGES;//記得要這句話
>>> mysql優(yōu)化表(回收表占用的閑置數(shù)據(jù)庫空間),代碼如何:
REPAIR TABLE `table_name` 修復(fù)表?
OPTIMIZE TABLE `table_name` 優(yōu)化表
?
1.備份表結(jié)構(gòu)(加上-d只備份表結(jié)構(gòu),不加此參數(shù)表結(jié)構(gòu)、數(shù)據(jù)都備份):
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqldump -hlocalhost -P3308 -uroot
-p -d stock_info>F:/stock_info.sql
Enter password: ******
?
備份單個(gè)表的數(shù)據(jù)(表必須不存在):
create table st_pool_bak as SELECT? id,code FROM `st_pool` ;
mysql 查看數(shù)據(jù)庫中所有表的記錄數(shù)(總記錄數(shù))use information_schema;
select table_name,table_rows from tables
where TABLE_SCHEMA = 'imora_scan'
order by table_rows desc;
MySQL LIMIT分頁優(yōu)化: SELECT * FROM `api_statistic` as apis
INNER JOIN (select id from api_statistic as ap2?? limit 1410000,10 ) as c using(id);
把字段合并成一條記錄返回: select GROUP_CONCAT(COLUMN_NAME) from information_schema.COLUMNS where table_name = 'biz_employee_cards';
select COLUMN_NAME from information_schema.COLUMNS where table_name = 'your_table_name' and table_schema = 'your_db_name';
GROUP_CONCAT ( url SEPARATOR " @ " ) 開啟mysql遠(yuǎn)程訪問端口: iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT service iptables save
轉(zhuǎn)載于:https://www.cnblogs.com/andydao/p/5447623.html
總結(jié)
以上是生活随笔為你收集整理的mysql管理员操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Scrum 团队成立 -- 软件工程
- 下一篇: 深入浅出KMP