赞
踩
释放压缩包
请确认您拥有视窗系统的管理员权限。
选择安装位置。按照惯例,mysql被安装在C:\mysql。
为了操作方便,我们设置一下视窗系统的环境变量。在系统变量中的path,添加路径,比如“C:\mysql\bin”。但是如果你的系统中需要运行多个MySQL服务器,那么就一定不要这样做了。
服务器使用网络端口,默认为3306。请设置防火墙的此端口为开放,或关闭防火墙。
创建一个配置文件
新建一个my.ini文件,内容如下所示:
(路径根据自己本地的实际进行录入。)
[mysqld]
# set basedir to your installation path
basedir=C:/dvp/mysql-8.0.18-winx64
# set datadir to the location of your data directory
datadir=C:/data/mysql
初始化数据目录
使用mysqld手动初始化data目录
执行mysqld命令如下所示:
C:\mysql\bin\mysqld --defaults-file=C:\mysql\my.ini --initialize --console
注意:如果命令执行失败,请以管理员的身份启动cmd,再执行以上的初始化命令。
注意保存控制台输出的随机密码。
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: cf;0F=cecFxq
从命令行启动mysql
新建批处理文件,mysql.bat。写入内容并执行:
C:\MySQL\bin\mysqld --defaults-file=C:\mysql\my.ini --console
然后执行:mysql -u root --skip-password
在连接后,为root设置新的密码:
注意不要忘记录入最后的分号!两个命令都试一下。
mysql> ALTER USER USER() IDENTIFIED WITH mysql_native_password BY 'password';
或者 mysql>ALTER USER 'root' @ 'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
系统会提示“Query OK, 0 rows affected (0.01 sec)”,没关系,这就是修改成功了。
注意:WITH mysql_native_password这个参数如果不加的话会报错。客户端连接可能会出现caching-sha2-password问题。
下载openssl在windows系统的安装包http://slproweb.com/products/Win32OpenSSL.html
设置环境变量。
生成密钥。
文件说明:
ca.pem Self-signed CA certificate
ca-key.pem CA private key
server-cert.pem Server certificate
server-key.pem Server private key
client-cert.pem Client certificate
client-key.pem Client private key
将生成的文件放到mysql\data文件夹。这样mysql启动后就自动启动ssl了。
检测mysql的安装
You can test whether the MySQL server is working by executing any of the following commands:
C:\> "C:\MySQL\bin\mysqlshow"
C:\> "C:\MySQL\bin\mysqlshow" -u root mysql
C:\> "C:\MySQL\bin\mysqladmin" version status proc
C:\> "C:\MySQL\bin\mysql" test
If mysqld is slow to respond to TCP/IP connections from client programs, there is probably a problem with your DNS. In this case, start mysqld with the --skip-name-resolve option and use only localhost and IP addresses in the Host column of the MySQL grant tables. (Be sure that an account exists that specifies an IP address or you may not be able to connect.)
You can force a MySQL client to use a named-pipe connection rather than TCP/IP by specifying the --pipe or --protocol=PIPEoption, or by specifying . (period) as the host name. Use the --socket option to specify the name of the pipe if you do not want to use the default pipe name.
If you have set a password for the root account, deleted the anonymous account, or created a new user account, then to connect to the MySQL server you must use the appropriate -u and -p options with the commands shown previously. See Section 5.2.2, “Connecting to the MySQL Server”.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。