####################配置文件开始################### # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It"s a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [client] default-character-set=utf8[mysqld] port=3306 basedir ="D:mysql-5.7.14-winx64" datadir ="D:mysql-5.7.14-winx64/data/" tmpdir ="D:mysql-5.7.14-winx64/data/" socket ="D:mysql-5.7.14-winx64/data/mysql.sock" log-error="D:mysql-5.7.14-winx64/data/mysql_error.log"#server_id = 2 #skip-lockingmax_connections=100 table_open_cache=256 query_cache_size=1Mtmp_table_size=32M thread_cache_size=8innodb_data_home_dir="D:mysql-5.7.14-winx64/data/" innodb_flush_log_at_trx_commit =1 innodb_log_buffer_size=128M innodb_buffer_pool_size=128M innodb_log_file_size=10M innodb_thread_concurrency=16 innodb-autoextend-increment=1000 join_buffer_size = 128M sort_buffer_size = 32M read_rnd_buffer_size = 32M max_allowed_packet = 32M explicit_defaults_for_timestamp=true sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"skip-grant-tables #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES####################配置文件结束###################2. 添加环境变量
4.登录Access denied for user "root"@"localhost" (using password: NO)问题解决
1).在mysql所在的根目录下找到my-default.ini,复制里面的全部内容,
新建一个txt文档,把内容复制进去,然后保存名字改为my.ini,注意需要把文件类型也改为ini,方法查看文件类型,然后把txt后缀改为ini,如果不懂可以上网查找。
2).my.ini配置文件,打开配置文件,找到[mysqld]一行,在下面添加skip-grant-tables后保存该文件,重新启mysql动服务。
----1.通过cmd进如到Mysql下的bin目录下,输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。
----2.进入mysql数据库:mysql> use mysql;Database changed
----3.输入update mysql.user set authentication_string=password("root") where user="root" ;
输入update mysql.user set authentication_string=password("root") where user="root" ;其中password("‘)中为你今后的密码。
重复的原因是因为跟5.7以前的输入方式不同。
原因是:新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入update mysql.user set password=password("root") where user="root"时提示ERROR 1054 (42S22): Unknown column "password" in "field list",原来是mysql数据库下已经没有password这个字段了,password字段改成了authentication_string,所 以如果按照用以前的update mysql.user set password=password("root") where user] ,就会报错。
----4.编辑my.ini文件删掉skip-grant-tables 这一行,然后重启MySQL,否则MySQL仍能免密码登录。
4.mysql error You must reset your password using ALTER USER statement before executing this statement.或者Your password has expired. To log in you must change it using a client that supports expired passwords.
5、设置编码问题(原文来自:设置MYSQL数据库编码为UTF-8)
1)、检查当前数据库编码。
使用语句:
show variables like ‘%character%"; show variables like"%collation%";2)、如果不是以上情况,需要将mysql编码设置为utf-8。具体步骤如下:
set character_set_client = utf8;另外:建立数据库时可以使用以下命令:
set character_set_server = utf8; set character_set_connection = utf8; set character_set_database = utf8; set character_set_results = utf8; set collation_connection = utf8_general_ci; set collation_database = utf8_general_ci; set collation_server = utf8_general_ci;
create database app_relation character set utf8; use app_relation; source app_relation.sql;修改数据库编码的命令为:alter database app_relation character set utf8;