mysql提示Can‘t connect to MySQL server on localhost (10061)解决方法

mysql提示Can’t connect to MySQL server on localhost (10061)解决方法
初次安装mysql,使用root密码登录失败,提示Can’t connect to MySQL server on localhost (10061),原因是mysql服务没有启动,
解决方法:将MySQL假如到windows服务后再启动。
1,将mysql加入到Windows的服务中。到mysql安装目录下的bin文件夹,输入命令运行"mysqld --install"

//第一次安装时
  C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqld --install
 Service successfully installed.

 //如果已经安装就是这样
 C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --install
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" MySQL

2,初始化mysql数据库,命令:“mysqld --initialize --user=root --console”
得到root密码,最后一行root@localhost:后的就是密码。如果已经初始化就不会得到root密码,需要先删除MySQL Server 5.7下的data文件。

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=root --console
//初始化
2021-02-27T03:24:31.941356Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-02-27T03:24:32.360862Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-02-27T03:24:32.423585Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-02-27T03:24:32.510522Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4efe9900-78ab-11eb-aa7d-b025aa27a9a6.
2021-02-27T03:24:32.514717Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-02-27T03:24:34.509725Z 0 [Warning] CA certificate ca.pem is self signed.
2021-02-27T03:24:35.239198Z 1 [Note] A temporary password is generated for root@localhost: Xalw;at8QyKk
//如果已经初始化
2021-02-27T03:38:27.342291Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-02-27T03:38:27.344372Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2021-02-27T03:38:27.344865Z 0 [ERROR] Aborting

3,登录mysql ,命令:“mysql -root -p”,输入初始化数据库得到的密码。

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -root -p
Enter password: ***

4,登录成功后使用set password for root@localhost = password(’!@QWas’); 修改root密码,命令结尾需要带分号。

其他
1,输入密码登录显示 “ERROR 1045 (28000): Access denied for user ‘ODBC’@‘localhost’ (using password: YES)”,
解决方法:使用uroot用户登录。

2,需要先修改密码才能使用mysql

mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

3,修改root密码
修改密码有多种方法,此为其一。登录mysql后使用 mysql> set password

for root@localhost = password(!@QWas');
 SET PASSWORD命令 
mysql> set password for root@localhost = password('!@QWas');
Query OK, 0 rows affected, 1 warning (0.00 sec)

4,如果修改密码一直出现 "->"符号,这是因为mysql的语句需要使用分号;;来结尾。加分号即可。

mysql> mysql> alter user 'root'@'localhost' identified by '123456'
    ->
    ->
    ->
    ->
    ->

5,mysql客户端
mysql客户端是以图像化界面操作mysql的软件,常用的navicat,workbench等。
workbench是免费的。
workbench下载路径: https://dev.mysql.com/downloads/workbench/

6,node连接mysql
https://www.runoob.com/mysql/mysql-connection.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值