白驹过隙,一晃,马上25的人了。是时候积累一点东西了,从点滴开始,希望自己能坚持,加油!
今天说MySQL安装,说一种,另一种未尝试。
1、从MySQL获取压缩文件(*.zip)
2、解压到自定义目录,如:D:\MySql
3、修改bin目录同级的my-default.ini文件,主要是设置几个必须参数。如:
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
basedir = D:\MySql
datadir = D:\MySql\data
port = 3306
server_id = mysql57
4、设置系统的环境变量,根据自己的MySQL目录而定。如:
;D:\MySql\bin (环境变量之间“;”分割,一定要注意)
5、进入cmd安装MySQL。命令:mysqld --initialize --user=root --console
正常执行会打印如下信息,这些信息中一定要记录下,随机生成的root的密码(我的root是Hk_r5hy%j#Oz)
2017-02-08T14:26:30.019744Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2017-02-08T14:26:32.704898Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-02-08T14:26:33.308933Z 0 [Warning] InnoDB: Creating foreign key constraint
system tables.
2017-02-08T14:26:33.444940Z 0 [Warning] No existing UUID has been found, so we a
ssume that this is the first time that this server has been started. Generating
a new UUID: 97282fa5-ee0a-11e6-a919-00ff77f97c57.
2017-02-08T14:26:33.536946Z 0 [Warning] Gtid table is not ready to be used. Tabl
e 'mysql.gtid_executed' cannot be opened.
2017-02-08T14:26:33.556947Z 1 [Note] A temporary password is generated for root@
localhost: Hk_r5hy%j#Oz
6、启动MySQL服务,命令:net start mysql
如果,启动时提示 “发生系统错误 2”,则需要进入MySQL的bin目录,
6、1 移除已初始化的MySQL,命令:mysqld -remove
6、2 重新初始化MySQL,命令:mysqld -install
初始化完成后,重新启动MySQL服务
7、登录MySQL,命令:mysql -u root -p 回车后,提示输入密码,这时需要输入上面产生的随机密码
8、修改root用户密码,这个方法很多,我用的如下命令。登录MySQL后执行
格式:mysql> set password for 用户名@localhost = password('新密码');
例子:mysql> set password for root@localhost = password('123');