部署过程中,将用mysqld命令配置好配置文件*.ini的位置,>mysqld --defaults-file=c:\sdk\mysql\my-default.ini --initialize;
编辑my.ini的基本配置,主要是basedir和datadir;
然后使用mysqld 命令初始化生成data文件夹,注意自动生成密码方式或者以无密码的方式初始化;
然后第一次运行mysql服务,可以在mysqld --console模式下,这样可以看到控制台的输出,>mysqld --console。注意运行成功的提示是Version: '5.7.10' socket: '' port: 3306 MySQL Community Server (GPL)。
打开新的cmd窗口,连接服务端,测试连接和服务端是否正常,使用自动生成的密码连接,时间间隔比较久会出现如下密码过期限制连接提示:
C:\sdk\mysql\bin>mysqlshow -u root
Enter password: ************
mysqlshow: Your password has expired. To log in you must change it using a client that supports expired passwords.
可以通过这样的方式更改密码:
C:\sdk\mysql\bin>mysqladmin -u root -p password
Enter password: ************
New password: ****
Confirm new password: ****
Warning: Since password will be sent to server in plain text, use ssl connection
to ensure password safety.
如果能连接mysql,也可以用这种方式更改密码:
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'
更改了密码,再测试mysql数据库服务连接如下,就成功了:
C:\sdk\mysql\bin>mysqlshow -u root -p
Enter password: ****
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+