mysql資料庫操作 登陸許可權等操作

2022-08-20 20:33:13 字數 1708 閱讀 4802

ctrl +l 清屏

ctrl +c 終止

\g 垂直分布的方式進行檢視

\s 檢視伺服器端資訊

[linux]

service mysql start 啟動mysql

service mysql stop 停止mysql

service mysql restart 重啟mysql

[windows] 在管理員許可權下執行

net start mysql 啟動mysql

net stop mysql 停止mysql

#

### part1

mysql -u使用者名稱 -p密碼 -h ip位址

#(1)登入到本地mysql 預設root 最高許可權賬戶

mysql -uroot -p123456

localhost => 127.0.0.1本地ip位址

#(2) 退出mysql

exit 或 \q

#(3) 遠端連線mysql伺服器

mysql -uroot -p -h192.168.48.128

#

查詢當前登入使用者是誰

select user()

#設定密碼

set password = password("

123456");

#去除密碼

set password = password('');

#

mysql 建立使用者

create user '

ceshi01

'@'192.168.11.66

' identified by '

111'; #

給具體ip設定賬戶

create user '

ceshi02

'@'192.168.11.%

' identified by "

111" ; #

給具體某個網段設定賬戶

create user '

ceshi03

'@'%

'; #

所有ip都能依靠ceshi03連線到該資料庫

#

檢視使用者許可權

show grants for

'ceshi03

'@'%';

#grant usage on *.* to 'ceshi03'@'%' | usage 無任何許可權

#grant 授權 [完整語法]

grant 許可權 on 資料庫.表名 to '

使用者名稱'%'

ip位址

' identified by '密碼'

;'''

select 查詢資料庫的許可權

insert 插入資料庫的許可權

update 更新資料庫的許可權

delete 刪除資料庫的許可權

'''#

授予查詢許可權,授權所有許可權用all

grant select on *.* to '

ceshi03

'@'%

' identified by '

222'

;grant all on *.* to '

ceshi03

'@'%

' identified by '

222';

mysql資料庫安全模式登陸

當使用mysql資料庫提示密碼錯誤或無許可權等問題時,可以通過mysql的安全模式啟動資料庫,使所有使用者可以完全訪問所有的表,可以對使用者重設密碼,也可以進行許可權修改。1 首先關閉mysql資料庫,並結束所有mysqld程序。service mysqld stop killall 9 mysql...

便簽8 資料庫登陸

1.資料庫知識點 php mysql資料庫程式設計的步驟 第一步 登入到mysql伺服器 第二步 選擇當前資料庫 第三步 設定請求資料的字符集 第四步 執行sql語句 link mysql connect db host,db user,db pwd echo php連線資料庫失敗!mysql er...

資料庫登陸1045錯誤

報錯內容 error 1045 28000 access denied for user root localhost using password yes 解決方法 1 停止mysql服務 有兩種方法 1.控制台輸入 net stop mysql 注意 這種情況需要在c盤中,用管理員的方式啟動cm...