mysql使用者名稱和密碼是root
所以登入-u接使用者名稱,-p接密碼,由於沒有密碼所以直接回車
[root@web01 mysql]# mysql -uroot -p
所以mysql不安全,需要給加密碼。
mysql設定密碼分兩種情況:
第一種情況:沒有密碼,設定密碼
設定密碼:
1
[root@web01 mysql]
設定完密碼後直接,輸入mysql就無法登陸
1
2
[root@web01 mysql]
# mysql
error 1045 (28000): access denied
for
user
'root'
@
'localhost'
(using password: no)
需要使用密碼才可以登陸mysql -uroot -poldboy123
1
2
3
4
5
6
7
8
9
10
[root@web01 mysql]
# mysql -uroot -poldboy123
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection
id
is 8
server version: 5.5.49 mysql community server (gpl)
/or
oracle is a registered trademark of oracle corporation and
/or
its
affiliates. other names may be trademarks of their respective
owners.
type
'help;'
or
'\h'
for
help. type
'\c'
to
clear
the current input statement.
mysql>
修改mysql的密碼為123456
1
2
3
4
5
6
7
8
9
10
11
12
13
[root@web01 mysql]
# mysqladmin -uroot -poldboy123 password 123456
[root@web01 mysql]
# mysql -uroot -poldboy123
error 1045 (28000): access denied
for
user
'root'
@
'localhost'
(using password: yes)
[root@web01 mysql]
# mysql -uroot -p123456
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection
id
is 11
server version: 5.5.49 mysql community server (gpl)
/or
oracle is a registered trademark of oracle corporation and
/or
its
affiliates. other names may be trademarks of their respective
owners.
type
'help;'
or
'\h'
for
help. type
'\c'
to
clear
the current input statement.
mysql>
登陸mysql後,會在history中留下mysql密碼,如何避免密碼洩露?
方法1:history -c清空所有歷史記錄
1
2
3
[root@web01 mysql]
# history -c
[root@web01 mysql]
# history
69
history
方法2:只清空帶有密碼的一條記錄的那行命令:history -d 歷史記錄號
1
2
3
4
5
6
7
8
9
10
11
[root@web01 mysql]
# history
69
history
70 mysql -uroot -p123456
71
history
[root@web01 mysql]
# history -d 70
[root@web01 mysql]
# history
69
history
70
history
71
history
-d 70
72
history
[root@web01 mysql]
#
sandshell
mysql使用技巧
1 分組查詢,並將組內的某個欄位值用逗號連線起來作為乙個新的字段,例如 select url,group concat type name as type names from music type group by url 即把同乙個url下面的type name欄位值用逗號連線起來。2 if函式...
mysql使用技巧
刪除表中資料 刪除整張表的資料 delete from 表名 匯入資料基本語法原文 一 loaddata 匯入資料的語法 load data infile 基本語法 複製 load data low priority local infile file name.txt replace ignore...
MySQL使用小技巧
1 忘記密碼 參考 如果你忘記了密碼,怎麼辦?我們可以開啟 etc my.cnf 檔案,在檔案最下面裡寫入 skip grant tables 儲存退出就可以了,然後記得重啟!然後就可以不用輸入密碼就進入了,然後進入之後修改密碼!如果你修改密碼的時候報這個錯 operation alter user...