标签:linux
mysql用户名和密码是root
所以登录-u接用户名,-p接密码,由于没有密码所以直接回车
[root@web01 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‘
设置密码:
[root@web01 mysql]# /application/mysql//bin/mysqladmin -u root password ‘oldboy123‘
设置完密码后直接,输入mysql就无法登陆
[root@web01 mysql]# mysql ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
需要使用密码才可以登陆mysql -uroot -poldboy123
[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) 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
[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) 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清空所有历史记录
[root@web01 mysql]# history -c [root@web01 mysql]# history 69 history
方法2:只清空带有密码的一条记录的那行命令:history -d 历史记录号
[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” 博客,请务必保留此出处http://sandshell.blog.51cto.com/9055959/1958824
标签:linux
原文地址:http://sandshell.blog.51cto.com/9055959/1958824