MySQL database installation

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/xiewenrui1996/article/details/100783596

Installing MySQL on Windows will be relatively simple, the latest version is available in  MySQL download  download in view.

Click the  Download  button to go to the download page, click on the figure below  No thanks, just start my download.  Download immediately:

 

Once downloaded, we will extract the zip package to the appropriate directory where the file after I unzip the folder on E: \ under MySQL \ mysql-8.0.17-winx64.

Next we need to configure the MySQL configuration file under

Open just unzip the folder  E: \ MySQL \ MySQL-8.0.17-Winx64 , the folder is created  my.ini  configuration file, edit the  my.ini  configure the following basic information:

[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
 
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=E:\MySQL\mysql-8.0.17-winx64
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=E:\MySQL\mysql-8.0.17-winx64
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

Next we start the next MySQL database:

Administrator cmd to open a command line tool, change directory:

Directly in the cmd input E: you can go to the installation directory

Initialize the database:

mysqld --initialize --console

After the execution is complete, the output initial root user's default password, such as:

...
2018-04-20T02:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ
...

APWCY5ws & hjQ is the initial password, subsequent logins need to use, you can also change the password upon login.

Enter the following command to install:

mysqld install

Start by entering the following command:

net start mysql

Log in MySQL

当 MySQL 服务已经运行时, 我们可以通过 MySQL 自带的客户端工具登录到 MySQL 数据库中, 首先打开命令提示符, 输入以下格式的命名:

mysql -h 主机名 -u 用户名 -p

参数说明:

  • -h : 指定客户端所要登录的 MySQL 主机名, 登录本机(localhost 或 127.0.0.1)该参数可以省略;
  • -u : 登录的用户名;
  • -p : 告诉服务器将会使用一个密码来登录, 如果所要登录的用户名密码为空, 可以忽略此选项。

如果我们要登录本机的 MySQL 数据库,只需要输入以下命令即可:

mysql -u root -p

按回车确认, 如果安装正确且 MySQL 正在运行, 会得到以下响应:

Enter password:

若密码存在, 输入密码登录, 不存在则直接按回车登录。登录成功后你将会看到 Welcome to the MySQL monitor... 的提示语。

然后命令提示符会一直以 mysq> 加一个闪烁的光标等待命令的输入, 输入 exit 或 quit 退出登录。

遇到的问题

服务名无效

这是因为你打开cmd没有用管理员权限打开,关闭再用管理员权限打开就可以了

登录时遇到Access denied for user 'root'@'localhost' (using password: YES)

原因一定是密码错误了,搞了我好久。。。。最后终于解决了。。。解决方法如下:

就是重新配置MySQL文件夹下的my.ini文件,改成下面的形式在登陆就可以了。其中basedir是你MySQL的路径

[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
 
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\\web\\mysql-8.0.11
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\web\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

 

Guess you like

Origin blog.csdn.net/xiewenrui1996/article/details/100783596