关于mysql 密码,编码问题
Posted 谷永辉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于mysql 密码,编码问题相关的知识,希望对你有一定的参考价值。
打开cmd终端,启动mysql,执行命令 net start mysql;
以root用户身份登录
mysql -u -root -p;
如果报错,
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
是应为在mysql5.6版本以后,就需要输入密码了,
设置新密码,123,下次再登录的时候就要输入密码123,
mysql> set password for root@localhost = password(‘123‘); Query OK, 0 rows affected, 1 warning (0.29 sec)
=====
查看数据库 ,可以看到已经创建的表
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | bookmanage1 | | bookmanage2 | | db1 | | db2 | | gu_orm | | myorm | | mysql | | performance_schema | | s5orm | | school | | sys | +--------------------+ 12 rows in set (0.06 sec)
选择自己要修改的编码的 数据库,然后可以看到表的表的信息,进行修改
mysql> use gu_orm; Database changed mysql> \s -------------- mysql Ver 14.14 Distrib 5.7.18, for Win64 (x86_64) Connection id: 70 Current database: gu_orm Current user: root@localhost SSL: Not in use Using delimiter: ; Server version: 5.7.18 MySQL Community Server (GPL) Protocol version: 10 Connection: localhost via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 14 hours 39 min 56 sec Threads: 4 Questions: 860 Slow queries: 0 Opens: 365 Flush tables: 1 Open tables: 256 Queries per second avg: 0.016 -------------- mysql> set character_set_client=utf8;------修改编码 Query OK, 0 rows affected (0.05 sec)
修改数据库的字符集mysql>use mydb
mysql>alter database mydb character set utf8;
创建数据库指定数据库的字符集
mysql>create database mydb character set utf8;
以上是关于关于mysql 密码,编码问题的主要内容,如果未能解决你的问题,请参考以下文章
关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4Unknown system variable ‘query_cache_size(代码片段
连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段