1.mysql的基本操作、配置

登录

mysql -h主机名 -P端口号 -u用户名 -p密码

mysql -hlocalhost -P 3306 -u root -pQa123456

 

 

 退出登录

exit
或 quit

 

 查询所有的库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.06 sec)

 

Mysql中编码的设置

mysql5.7及之前的版本默认使用拉丁文的编码方式,存储中文会报错

需要修改配置文件

mysql8.0及之后使用默认就可以。无需另外配置

查看编码命令

mysql> show variables like 'character_%';
+--------------------------+--------------------------------------------------------+
| Variable_name            | Value                                                  |
+--------------------------+--------------------------------------------------------+
| character_set_client     | utf8mb4                                                |
| character_set_connection | utf8mb4                                                |
| character_set_database   | utf8mb4                                                |
| character_set_filesystem | binary                                                 |
| character_set_results    | utf8mb4                                                |
| character_set_server     | utf8mb4                                                |
| character_set_system     | utf8mb3                                                |
| character_sets_dir       | /usr/local/mysql-8.0.26-macos11-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.02 sec)

 

mysql> show variables like 'collation_%';
+----------------------+--------------------+
| Variable_name        | Value              |
+----------------------+--------------------+
| collation_connection | utf8mb4_0900_ai_ci |
| collation_database   | utf8mb4_0900_ai_ci |
| collation_server     | utf8mb4_0900_ai_ci |
+----------------------+--------------------+
3 rows in set (0.01 sec)

 

解决:SQLyog上报2058错误

 

解决:root用户忘记密码 

 

 解决:不是内部或外部命令问题

环境变量配置有问题

解决:没有选择数据库就操作表格和数据

 

posted @ 2022-12-04 01:39  邵杠杠  阅读(33)  评论(0编辑  收藏  举报