1、Mysql客户端安装
安装教程
ps:以下教程基于window
2、启动
- 进入到bin(上述数据库安装目录):
cd C:\xx\MySQL\MySQL Server 5.7\bin
# 否则找不到mysqld(或者配置环境变量) - 初始化data目录:
mysqld --initialize --user=mysql --console
- 安装:
mysqld -install
- 启动mysql :
net start mysql
- 若未安装或初始化就启动mysql,则报错:
MySQL服务无法启动
- 初始化data报错:
initialize specified but the data directory has files in it. Aborting.
,则先删除data 再次初始化
3、命令行登录
Mysql安装成功后,默认的root用户密码为空,你可以使用以下命令来创建root用户的密码:mysql -u root password "new_password";
mysql -h 主机 -u 用户名 -P 端口号(默认3306) -p
C:\WINDOWS\system32>mysql -h localhost -u root -P 3306 -p
Enter password: ****** # 输入密码
Welcome to the MySQL monitor. Commands end with ; or \g. # 表示登录成功
Your MySQL connection id is 3
Server version: 5.7.39-log MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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>
C:\WINDOWS\system32>mysql -u root -p
Enter password: ****
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
==> 先确定mysql服务是否启动(服务-mysql,确认状态是否是正在运行)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
==>密码错误
4、退出登录
exit
或quit
mysql> quit
Bye
网友评论