mysql的配置文件中强烈建议

修改mysql提示符prompt
类似于LINUX中的PS1
效果展示:

[root@centos7 support-files]# mysql -uroot -pcentos123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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.

08:40:11(root@localhost) [(none)]> 

临时修改:

[root@centos7 ~]#mysql -uroot -pcentos123 --prompt="\\r:\\m:\\s(\\u@\\h) [\\d]>\\_"
[root@centos7 ~]#export MYSQL_PS1="\\r:\\m:\\s(\\u@\\h) [\\d]>\\_"

永久修改:

[root@centos7 ~]#vim /etc/my.cnf.d/mysql-clients.cnf 
[mysql]
prompt="\\r:\\m:\\s(\\u@\\h) [\\d]>\\_"  
或
prompt=mysql(\\u@\\h:\\d)>

查看
[root@centos7 support-files]# mysql  --print-defaults
mysql would have been started with the following arguments:
--socket=/data/mysql/mysql.sock --prompt=\r:\m:\s(\u@\h) [\d]>\_ 

问题:mysqladmin无法识别,有知道怎么解决的小伙伴欢迎留言,谢谢
[root@centos7 support-files]# mysqladmin -uroot -pcentos123 ping
mysqladmin: [ERROR] unknown variable ‘prompt=mysql(\u@\h:\d)>’

增加一定的限制条件,防止修改所有行的指定字段

  -U, --safe-updates  Only allow UPDATE and DELETE that uses keys.
  -U, --i-am-a-dummy  Synonym for option --safe-updates, -U.

用法:临时

mysql -U | --safe-updates| --i-am-a-dummy

永久

[root@centos7 ~]#vim /etc/my.cnf
[mysql]
safe-updates

新建数据库修改默认字符集
说明:mysql默认latin,存储中文会出现乱码,同时保存图片,需用utf8mb4

vim /etc/my.cnf
[mysqld]
character-set-server=utf8mb4
[mysql]
default-character-set=utf8mb4

猜你喜欢

转载自blog.csdn.net/weixin_50904580/article/details/111566662