以下代码需要root管理员权限

刚在linux中装完mysql,想用默认密码登录,结果:

获取默认密码:
grep 'temporary password' /var/log/mysqld.log
//后面是我的mysql路径
默认密码打印:
2020-01-08T01:52:01.156018Z 1 [Note] A temporary password is generated for root@localhost: i7jqp!Q8lwoX
//i7jqp!Q8lwoX就是我的默认密码
准备登录:
mysql -uroot -pi7jqp!Q8lwoX			//敲回车
bash: !Q8lwoX: event not found		//报错
解决:
//因为linux中的!是特殊字符,会造成影响,我们需要将其转义:
mysql -uroot -pi7jqp\!Q8lwoX		//在这个!前加一个\转义即可


//成功登录:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23

Copyright (c) 2000, 2018, 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.
网上找的linux中可能会对输入代码造成影响的特殊字符:

; ;; . , / \ ‘string’| ! $ ${} $? $$ $* “string”* ** ? : ^ $# $@ command{} [] [[]] () (()) || && {xx,yy,zz,…}~ ~+ ~- & <…> + - %= == !=

中间有空格,大家看仔细一点=-=
Logo

更多推荐