从官网下载MySQL-5.7.11-winx64压缩版,安装后发现竟然有密码,尝试无果,通过修改密码搞定
安装成功后:
关闭mysql服务在跟目录下修改文件my.ini,内容如下:注意两点 1:内容中myql的安装目录换成读者的安装目录;2最后一行代表登录是否需要密码,这里我们绕过密码登录进入mysql修改密码,所以不注释skip-grant-tables
####################配置文件开始################### # 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 # D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64 basedir ="D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/" datadir ="D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/" tmpdir ="D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/" socket ="D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/mysql.sock" log-error="D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-winx64/data/mysql_error.log" #server_id = 2 #skip-locking max_connections=100 table_open_cache=256 query_cache_size=1M tmp_table_size=32M thread_cache_size=8 innodb_data_home_dir="D:\Program Files\mysql-5.7.11-winx64\mysql-5.7.11-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 ####################配置文件结束###################
修改保存后,在cmd中,由于我们已经在path配置了环境变量,所以我们可以直接启动mysql
net start mysql
启动成功后,登录mysql
mysql -u root -p
密码为空 这里我们直接回车登录成功
登录成功后,我们修改数据库执行如下
use mysql
update user set authentication_string=password("123456") where user="root";
这里注意最后必需加上分号
成功后刷新
flush privileges;
致此我们密码就修改成功了,退出关闭mysql服务,然后把my.ini中最后一行注释掉,从新启动mysql服务,发现新密码生效。
以上就是mysql 5.7.11 修改winx64初始密码的方法的详细内容,更多请关注php中文网其它相关文章!
……