mysql 安装及设置

时间:2022-05-19 06:43:48

mysql下载安装记录

设备情况:win10,之前没有进行过mysql安装。
一下载:直接官网下载,https://dev.mysql.com/downloads/file/?id=490026 下载的是解压版的。版本8.0.18 压缩包270M左右。下载完之后解压。

二安装 : 参照 https://www.runoob.com/mysql/mysql-install.html 注意:cmd要用 【管理员权限】启动->在这里C:WindowsSystem32cmd.exe 然后运行到mysqld -install的时候
下一步net start mysql 可能会出错:

D:mysql-8.0.18-winx64bin>net start mysql
发生系统错误 193。

*** 不是有效的 Win32 应用程序。

这时候看这篇博客,原理好像是第一次默认安装在c盘,需要手动删除,然后remove一下,再次安装,就到你的指定的目录了。然后再net启动,就成功了

https://blog.csdn.net/qq_35164169/article/details/77863600

 

下面是我的安装过程;
C:Windowssystem32>d:

D:mysql-8.0.18-winx64bin>mysqld install
Service successfully installed.

D:mysql-8.0.18-winx64bin>net start mysql
发生系统错误 193。

*** 不是有效的 Win32 应用程序。


D:mysql-8.0.18-winx64bin>mysqld install
The service already exists!
The current server installed: C:Windowssystem32mysqld MySQL

D:mysql-8.0.18-winx64bin>c:

C:WindowsSystem32>d:

D:mysql-8.0.18-winx64bin>mysqld remove
Service successfully removed.

D:mysql-8.0.18-winx64bin>mysqld -install
Service successfully installed.

D:mysql-8.0.18-winx64bin>mysqld -install
The service already exists!
The current server installed: D:mysql-8.0.18-winx64binmysqld MySQL

D:mysql-8.0.18-winx64bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。


D:mysql-8.0.18-winx64bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.18

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.

mysql>

到这里就安装完成了,且完成了登录。

 

 

 


cd D:mysql-8.0.18-winx64bin

Xkm?o-<aR4d=

D:mysql-8.0.18-winx64bin>
D:mysql-8.0.18-winx64bin>mysqld --initialize --console
2019-10-28T00:52:20.344670Z 0 [System] [MY-013169] [Server] D:mysql-8.0.18-winx64binmysqld.exe (mysqld 8.0.18) initializing of server in progress as process 12956
2019-10-28T00:52:21.724707Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: Xkm?o-<aR4d=


D:mysql-8.0.18-winx64bin>mysqld --initialize --console
2019-10-28T00:58:45.711083Z 0 [System] [MY-013169] [Server] D:mysql-8.0.18-winx64binmysqld.exe (mysqld 8.0.18) initializing of server in progress as process 1104
2019-10-28T00:58:45.712542Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2019-10-28T00:58:45.712555Z 0 [ERROR] [MY-013236] [Server] The designated data directory D:mysql-8.0.18-winx64data is unusable. You can remove all files that the server added to it.
2019-10-28T00:58:45.718481Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-10-28T00:58:45.719322Z 0 [System] [MY-010910] [Server] D:mysql-8.0.18-winx64binmysqld.exe: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.

# datadir=D:mysql-8.0.18-winx64

 

//这个可以用 先创建用户,然后分配权限;%可以远程连接 修改后可以在workbench上登录
CREATE USER ‘zhangsan‘@‘%‘ IDENTIFIED BY ‘123456‘;
GRANT ALL PRIVILEGES ON lskj.* TO ‘zhangsan‘@‘%‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;


//修改远程登录方法 可以在vs上使用。
ALTER USER ‘zhangsan‘@‘%‘ IDENTIFIED BY ‘123456‘ PASSWORD EXPIRE NEVER;
ALTER USER ‘zhangsan‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘123456‘;
FLUSH PRIVILEGES;