-----情景:总是出现类似的错误-----
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
O)
-----解决方案-----
1.没有忘记mysql登陆密码的话
(本人主机上密码暂时是我名字拼音)
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.20 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>
2.如果忘记mysql登陆密码了
则重新安装mysql dmg安装包,则会重新分配一个密码(5.7.23左右版本才有,5.6都没有):
有时发现重新安装出现不了这个密码,则去/usr/local下路径删除下mysql的文件,重新安装即可
3)重新设置root密码:
SET PASSWORD = PASSWORD('jianan123456');
有时候怎么输都不对,这是需要先关闭mysql,然后再次
安装-->重启-->输入
3.导入数据库
创建数据库
create database pomelo;
use pomelo;
展示当前所有数据库
show databases;
用source命令根据备份的mysql.sql语句导入数据库
mysql> source /Users/jianan/Documents/StudyMaster/bycw_nodejs_game/bycw_server/sql/bycw_game_node.sql
4.有时候,安装完mysql客户端,输入mysql无法识别,这是没有加入环境变量的原因
export PATH="/usr/local/mysql-8.0.12-macos10.13-x86_64/bin:$PATH"