hi,欢迎访问本站!
当前位置: 首页系统/服务器正文

win10系统安装MySQL5.7.30遇到的小坑,user表中不在有password字段而是authentication_string,my.ini文件中的路径写法遇坑问题

墨初 系统/服务器 1阅读
1. mysql 版本选择 

官方:https://dev.mysql.com/downloads/mysql/ 

严格按照截图的数字顺序选择 

到这里就下载完了。

 

2. 使用压缩包下载安装步骤

下面是my.ini内容: [client]# 设置mysql客户端默认字符集default-character-set=utf8[mysqld]# 设置3306端口port=3306character_set_server=utf8# 解压目录basedir=C:\\robotcoach\\mysql# 解压目录下data目录datadir=C:\\robotcoach\\mysql\\datadefault-storage-engine=INNODBsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES[WinMySQLAdmin]C:\\robotcoach\\mysql\\bin\\mysqld.exe

备注:上面设计的xxxx\\data  ,这个data目录不是自己手动建好的,配置好一个目录就好,后面执行命令会自动建好该data目录!!!

my.ini配置完成以后,继续往下仔细看:

a:点击win图标,输入dos ,当出现cmd的黑色命令框时候,右击“以管理员身份运行”或者看到dos旁边有“以管理员身份运行”可以点击【win10系统是后者,其他不清楚】,一句话要用管理员身份运行dos窗口!,如下截图:

注意:如果不是管理员命令执行,会报错:Install/Remove of the Service Denied! 的提示错误。

b:打开cmd.exe,输入命令: mysqld -install:

 

C:\Windows\system32>mysqld -installService successfully installed.//以下是错误的演示,因为前面的图中每个路径用的单个\,而非\\ 的原因C:\Windows\system32> mysqld --initialize-insecure --user=mysql[0x7FFF1B1EE044] ANOMAL Y: use of REX.w is meaningless (default operand size is 64)obotcoach\mysql\data\is_writable' (Errcode: 2 - No such file or directory)2021-03-04T08:29:14.011250Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2021-03-04T08:29:14.011299Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.2021-03-04T08:29:14.011303Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.obotcoach\mysql\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.2021-03-04T08:29:14.014800Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.2021-03-04T08:29:14.015198Z 0 [ERROR] Aborting//将\ 改成\\以后重试命令,不在报错,出现ok

c:  C:\Windows\system32>mysqld --initialize-insecure --user=mysql   有几秒的间隔,不报错就是表示初始化成功,执行完这条命令,这时mysql就帮你自己创建一个data文件夹。

到这里 mysql的win10版本就安装ok了。

3.navicat premium 链接 mysql 完美测试

安装完mysql,启动操作下如图:

C:\Windows\system32>net start mysql[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)MySQL 服务正在启动 .MySQL 服务已经启动成功。C:\Windows\system32>net stop mysql[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)MySQL 服务正在停止.MySQL 服务已成功停止。C:\Windows\system32>services.msc ##这里可以不操作,只是看一下相关mysql服务通过cmd的命令执 ## 行情况.C:\Windows\system32>net start mysql[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)MySQL 服务正在启动 .MySQL 服务已经启动成功。C:\Windows\system32>mysql -uroot ##我这里不知道初始化的密码是什么,所以我打算想办法进入到库 ##表中,更改密码等操作[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.30 MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)mysql> use mysqlDatabase changedmysql> show tables;+---------------------------+| Tables_in_mysql |+---------------------------+| columns_priv || db || engine_cost || event || func || general_log || gtid_executed || help_category || help_keyword || help_relation || help_topic || innodb_index_stats || innodb_table_stats || ndb_binlog_index || plugin || proc || procs_priv || proxies_priv || server_cost || servers || slave_master_info || slave_relay_log_info || slave_worker_info || slow_log || tables_priv || time_zone || time_zone_leap_second || time_zone_name || time_zone_transition || time_zone_transition_type || user |+---------------------------+31 rows in set (0.00 sec)mysql> select user,host ,authentication_string from user ;+---------------+-----------+-------------------------------------------+| user | host | authentication_string |+---------------+-----------+-------------------------------------------+| root | localhost | || mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE || mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |+---------------+-----------+-------------------------------------------+3 rows in set (0.00 sec)mysql> select user,host ,password from user ; ##5.7.xx版本没有password这个字段了,改为 ## authentication_string ERROR 1054 (42S22): Unknown column 'password' in 'field list'mysql> use mysqlDatabase changedmysql> update user set authentication_string=password("123456") where user="root"; ##修改Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 1mysql> flush privileges; ##必须flush 不然不刷新直接退出 仍然下次登陆不了!Query OK, 0 rows affected (0.00 sec)mysql> quitByeC:\Windows\system32>mysql -uroot -p123456[0x7FFF1B1EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 9Server version: 5.7.30 MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)mysql>

注意:mysql> update user set authentication_string=password("123456") where user="root"; ##修改语句,其中 authentication_string不在是password字段,且后边紧跟着 flush privileges;   ##必须flush  不然不刷新直接退出  仍然下次登陆不了!

使用navicat  premium链接如图:

4 .总结

遇到问题不是盲目查找帖子的,系统梳理步骤和顺序,可能自己就能解决,最后:问题不大,win10笔记本安装,其实遇到的小坑就是\\的问题,其他都很简单,记录下来防止过多的看帖子。不要眼高手低,因为笔记本是新装的系统,没成想安装一遍mysql还遇到了一个小坑。仅此。

 

 

标签:
声明:无特别说明,转载请标明本文来源!