解决权限问题:
mutoudeAir:~ linminsheng$ /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11 MySQL Community Server - GPL
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.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb_2017050601 |
| mysql |
| nihao |
| performance_schema |
| springmvc |
| sys |
+--------------------+
7 rows in set (0.02 sec)
mysql> use springmvc
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
-> ;
+---------------------+
| Tables_in_springmvc |
+---------------------+
| Item |
| user |
+---------------------+
2 rows in set (0.00 sec)
mysql> desc Item;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| id | int(10) | NO | PRI | NULL | |
| name | varchar(255) | YES | | NULL | |
| price | double(10,2) | YES | | NULL | |
| date | date | YES | | NULL | |
| datail | varchar(255) | YES | | NULL | |
+--------+--------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mysql> status;
--------------
mysql Ver 8.0.11 for macos10.13 on x86_64 (MySQL Community Server - GPL)
Connection id: 11
Current database: springmvc
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.11 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /tmp/mysql.sock
Uptime: 1 hour 43 min 56 sec
Threads: 3 Questions: 52 Slow queries: 0 Opens: 193 Flush tables: 2 Open tables: 169 Queries per second avg: 0.008
--------------
mysql> use springmvc;
Database changed
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '831Lms,./';
Query OK, 0 rows affected (0.08 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
解决权限问题:
在jdbc:mysql://127.0.0.1:3306/test后面加上 ?useUnicode=true&characterEncoding=utf8
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="context1">
<jdbcConnection connectionURL="jdbc:mysql://localhost:3306/springmvc?characterEncoding=utf8"
driverClass="com.mysql.jdbc.Driver" password="831Lms,./" userId="root" />
<!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="com.itheima.springmvc.pojo" targetProject="03-springmvc-mybatis/src/" />
<!-- 生成映射文件的包名和位置 -->
<sqlMapGenerator targetPackage="com.itheima.springmvc.mapper" targetProject="03-springmvc-mybatis/src/" />
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator targetPackage="com.itheima.springmvc.dao" targetProject="03-springmvc-mybatis/src/" type="XMLMAPPER" />
<table schema="" tableName="Item">
</table>
<table schema="" tableName="user">
</table>
</context>
</generatorConfiguration>