mysql使用技巧
阿新 • • 發佈:2017-08-24
linux
mysql用戶名和密碼是root
所以登錄-u接用戶名,-p接密碼,由於沒有密碼所以直接回車
[[email protected] mysql]# mysql -uroot -p
所以mysql不安全,需要給加密碼。
mysql設置密碼分兩種情況:
第一種情況:沒有密碼,設置密碼
/application/mysql//bin/mysqladmin -u root password ‘new-password‘
第二種情況:有密碼,需要修改密碼
/application/mysql//bin/mysqladmin -u root -h web01 password ‘new-password‘
設置密碼:
[[email protected] mysql]# /application/mysql//bin/mysqladmin -u root password ‘oldboy123‘
設置完密碼後直接,輸入mysql就無法登陸
[[email protected] mysql]# mysql ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
需要使用密碼才可以登陸mysql -uroot -poldboy123
[[email protected] 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) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 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
[[email protected] mysql]# mysqladmin -uroot -poldboy123 password 123456 [[email protected] mysql]# mysql -uroot -poldboy123 ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES) [[email protected] 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) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 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清空所有歷史記錄
[[email protected] mysql]# history -c [[email protected] mysql]# history 69 history
方法2:只清空帶有密碼的一條記錄的那行命令:history -d 歷史記錄號
[[email protected] mysql]# history 69 history 70 mysql -uroot -p123456 71 history [[email protected] mysql]# history -d 70 [[email protected] mysql]# history 69 history 70 history 71 history -d 70 72 history [[email protected] mysql]#
本文出自 “sandshell” 博客,請務必保留此出處http://sandshell.blog.51cto.com/9055959/1958824
mysql使用技巧