Window Mysql-5.7.26-winx64 decompression Installation / MySQL can not resolve the situation after the installation of remote access

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/bj_chengrong/article/details/90295376

1. Download: Address: http: //dev.mysql.com/downloads/mysql/

2. Install:

Download mysql-5.7.26-winx64 compress an entire directory on the package and extract their favorite position, I put E under the root directory

 

3. Configure :( default may not have this file, create your own)

Enter mysql-5.7.26-winx64 directory, inside my-default.ini copy of the document, and named my.ini

================================================== =========== my.ini

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]
character_set_server=utf8
lower_case_table_names=1
max_allowed_packet=100M
bind-address = 0.0.0.0

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

basedir = E:\mysql-5.7.26-winx64

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

=============================================================

4.安装mysql服务并启动:以管理员身份打开cmd窗口后,将目录切换到你解压文件的bin目录

再输入mysqld install回车运行就行了

接着就是输入 net start mysql 启动服务,会提示mysql无法启动服务

注意:此时MySQL可能会卡在系统服务中,无法关闭,重启也没用,那么执行下面进行KILL服务

可能会报错:“ 服务正在启动或停止中,请稍候片刻后再试一次”

-- 查看无法启动的MySQL服务所在
1、 tasklist| findstr "mysql" 
-- 进行手动KILL掉
2、taskkill/f /t /im mysqld.exe
-- 检查是否还在,如果还有其他的服务在,用上面的命令KILL
3、tasklist| findstr "mysql"

接着往下执行:

切换MySQL的bin执行:

mysqld --initialize-insecure --user=mysql (如果没有创建my.ini文件的情况下,同时会在根目录创建data文件)

我们再输入mysqld --initialize-insecure --user=mysql(执行完这条命令后,MySQL会自建一个data文件夹,并且建好默认数据库,登录的用户名为root,密码为空)

或者:  mysqld  --initialize(已创建my.ini文件的情况)

 

 

再次启动:再输入 net start mysql 启动服务

5.打开MySQL数据库即登录MySQL数据库。

还在命令模式下,将目录切换到自己的\bin目录下。
输入mysql -u root -p ,默认是没有密码的。回车进入,root是用户名 

6.配置个mysql环境变量。

配置好环境变量之后,就可以直接cmd之后,不用进入目录,然后输入mysql -u root -p,就打开MySQL数据库了,当然你的服务必须启动先,不然还是不行。

mysql启动服务有两种:

 a:在计算机管理-服务和应用程序-服务

b:就是在lib目录下管理员命令运行net start mysql命令

开始配置环境变量:

到这里我们的mysql就算是安装完成了,下面我们来测试一下,接着上面的命令窗口直接输入show databases;

再测试环境变量:

关闭命令窗口,重新打开一个新的cmd命令窗口直接输入mysql -u root -p就能进入mysql说明环境变量已经配置正确

5、以上是Mysql的安装完成,现在开始远程访问,修改密码等操作

-- MySQL登录
mysql -u root -p
--检查端口是否是3306
show global variables like 'port'

5.2、修改密码(依次执行)

mysql -u root -p --登录

use mysql;  --切换数据库

update mysql.user set password=password('bgy123') where user='root';  --修改root用户密码
flush privileges;

5.3、--增加远程登录权限

grant all privileges on *.* to root@'%' identified by 'root';
flush privileges;

重启mysql服务

如果以上还不能解决MySQL的远程连接问题,那么请看下面:

mysql -u root -p --登录

输入密码:bgy123

执行:select host,user from user;

需要把红色的这条记录删除掉

执行:delete from user where host='localhost' and user = 'root';

再进行查询:select host,user from user;

已经删除掉了,再去尝试远程连接是否可用! 记得把防火墙关闭!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/bj_chengrong/article/details/90295376