mysql 常用語句

2022-07-01 01:24:16 字數 3283 閱讀 7022

set password for root@localhost = password('123456');

mysqldump --single-transaction --set-gtid-purged=off nacos_config >nacos_config.sql  #不鎖表匯出資料庫

mysqldump --single-transaction --flush-logs --master-data=2 --quick --routines --triggers --databases update >update_backup.sql

grant select on database1.* to 'username'@'%' identified by 'password';

mysql_config_editor set -uroot -p #免密登入

123456

select user,host from mysql.user;  #檢視使用者許可權

create database cloud;

create database timeline;

show databases;

use cloud

show tables;

desc config;

mysqldump --set-gtid-purged=off cloud config > 20200827_sh-hw_to_sh2-hw_cloud_config.sql

mysql cloud < 20200518_jd-cloud_to_qd-cloud.sql

mysql cloud < 20200518_jd-cloud-config_to_qd-cloud-config.sql

create user 'test'@'%' identified by 'test';

create user 'test'@'10.24.%' identified by 'test';

grant all privileges on *.* to 'test'@'%'; #使用者享受特權

grant all on cloud.* to test@'%';

flush privileges;

create user test@'%' identified by '123456';

grant all privileges on *.* to test@'%';

grant create,alter,drop,select,insert,update,delete on cloud.* to test@'192.168.%';

select distinct concat('user: ''',user,'''@''',host,''';') as query from mysql.user;

select distinct concat('user: ''',user,'''@''',host,''';') as query from cloud.user;

show grants for 'dev'@'%';

show grants for 'root'@'%';

show grants for 'root'@'192.168.%';

show grants for 'dev'@'192.168.%';

yum localinstall -y mysql-community-libs-5.7.28-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm \

mysql-community-common-5.7.28-1.el7.x86_64.rpm mysql-community-client-5.7.28-1.el7.x86_64.rpm mysql-community-server-5.7.28-1.el7.x86_64.rpm

grep "password" /var/log/mysqld.log

mysql -uroot -p

alter user root@localhost identified by 'closeli01@123';

mysqldump cloud >cloud.sql

mysql> create database cloud; # 建立資料庫

mysql> use cloud; # 使用已建立的資料庫

mysql> set names utf8; # 設定編碼

mysql> source cloud.sql # 匯入備份資料庫

mysql> show variables like "%password%";

mysql> set global validate_password_length=0;

mysql> alter user user() identified by '';

mysql> select host,user from mysql.user;

mysql> create user 'dev'@'10.0.0.%' identified by 'dev';

mysql> drop user 'dev'@'10.0.0.%';

grant all privileges on cloud.* to 'dev'@'10.0.0.%' identified by 'dev';

grant all privileges on cloud.* to 'dev'@'10.0.0.%';

mysql> flush privileges;

mysql> show grants;

mysql> show grants for 'dev'@'10.0.0.%';

/*授予使用者通過外網ip對於該資料庫的全部許可權*/

grant all privileges on `test`.* to 'test'@'%' ;

/*授予使用者在本地伺服器對該資料庫的全部許可權*/

grant all privileges on `test`.* to 'test'@'localhost';

grant select on test.* to 'user1'@'localhost'; /*給予查詢許可權*/

grant insert on test.* to 'user1'@'localhost'; /*新增插入許可權*/

grant delete on test.* to 'user1'@'localhost'; /*新增刪除許可權*/

grant update on test.* to 'user1'@'localhost'; /*新增許可權*/

flush privileges; /*重新整理許可權*/%

mysql常用語句 MySQL常用語句

create table student id int primary key auto increment comment 學號 name varchar 200 comment 姓名 age int comment 年齡 comment 學生資訊 修改表注釋 alter table studen...

php mysql 常用語句 mysql常用語句

一 修改mysql使用者密碼 mysql h localhost u root p 命令列登入 update user set password password 123456 where user root 二 資料庫操作 show databases 顯示資料庫 create database ...

MySQL常用語句

and和or可以混用,and比or具有更高的優先順序,但盡量使用圓括號區分 自動過濾重複的資料owner,關鍵字distinct select distinct owner from pet 按照生日公升序排列,關鍵字order by select name,birth from pet order...