win10下新版MYSQL报10061错误
程序员文章站
2022-06-12 23:36:51
...
垃圾,,死垃圾。一个破玩意,安装起来就不能用。什么狗屁玩意。
问题描述:在命令行输入 mysql -u root -p 登录mysql,返回”Can't connect to MySQL server on localhost (10061)”错误
问题原因:在一番谷歌后,查到问题原因是mysql没有启动。
记住:先用管理员权限打开CMD命令行模式。
解决方法:1、将mysql加入到Windows的服务中。切换到mysql安装目录下的bin文件夹,命令行运行"mysqld --install"
1 C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqld --install
2 Service successfully installed.
此时若使用“net start mysql”成功启动msyql,则无须执行下面步骤
2、初始化mysql数据库,输入“mysqld --initialize --user=root --console”。下面红色文字为初始化后的root 密码
复制代码
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=root --console
2016-10-29T01:35:44.309833Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2016-10-29T01:35:46.659968Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-10-29T01:35:47.154996Z 0 [Warning] InnoDB: Creating foreign key constraintsystem tables.
2016-10-29T01:35:47.362008Z 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: 043563f4-9d78-11e6-a8c8-606dc79c383c.
2016-10-29T01:35:47.388009Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-10-29T01:35:47.401010Z 1 [Note] A temporary password is generated for root@localhost: u).ig.Gd.7hW
复制代码
3、此时使用“net start mysql”成功启动msyql
4、使用生成的密码登录mysql,通过“set password=password('123456')”修改密码。此处将root密码设置为123456
mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
过程中碰到另一个问题:
C:\Windows\system32>mysqld --initialize --user=root --console
2019-06-03T13:05:54.670437Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-03T13:05:54.674845Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-06-03T13:05:54.675411Z 0 [ERROR] Aborting
之前手动新建了一个DATA文件夹用来放MY.INI,这里报错。直接删除这个文件夹即可。
问题描述:在命令行输入 mysql -u root -p 登录mysql,返回”Can't connect to MySQL server on localhost (10061)”错误
问题原因:在一番谷歌后,查到问题原因是mysql没有启动。
记住:先用管理员权限打开CMD命令行模式。
解决方法:1、将mysql加入到Windows的服务中。切换到mysql安装目录下的bin文件夹,命令行运行"mysqld --install"
1 C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqld --install
2 Service successfully installed.
此时若使用“net start mysql”成功启动msyql,则无须执行下面步骤
2、初始化mysql数据库,输入“mysqld --initialize --user=root --console”。下面红色文字为初始化后的root 密码
复制代码
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=root --console
2016-10-29T01:35:44.309833Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2016-10-29T01:35:46.659968Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-10-29T01:35:47.154996Z 0 [Warning] InnoDB: Creating foreign key constraintsystem tables.
2016-10-29T01:35:47.362008Z 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: 043563f4-9d78-11e6-a8c8-606dc79c383c.
2016-10-29T01:35:47.388009Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-10-29T01:35:47.401010Z 1 [Note] A temporary password is generated for root@localhost: u).ig.Gd.7hW
复制代码
3、此时使用“net start mysql”成功启动msyql
4、使用生成的密码登录mysql,通过“set password=password('123456')”修改密码。此处将root密码设置为123456
mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
过程中碰到另一个问题:
C:\Windows\system32>mysqld --initialize --user=root --console
2019-06-03T13:05:54.670437Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-03T13:05:54.674845Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-06-03T13:05:54.675411Z 0 [ERROR] Aborting
之前手动新建了一个DATA文件夹用来放MY.INI,这里报错。直接删除这个文件夹即可。
下一篇: GSON JSON解析 gsonjson
推荐阅读