服务器开发---开发环境配置

来源:互联网 发布:2016年实体店倒闭数据 编辑:程序博客网 时间:2024/05/21 09:19

近期准备做服务器开开发,首先得配置开发环境,个人总结如下:

一,IDE环境 使用 myeclipse-2017stable1.0.网上教程很多,不在赘述。

二,数据库采用mysql 5.7.18 社区版带解压包的。

参考文章mysql5.7.18解压版启动mysql服务

【1】下载mysql社区版 
【2】解压到D:\Program Files,新建环境变量MYSQL_HOME=D:\Program Files\mysql-5.7.19-winx64,然后在path变量中加入;%MYSQL_HOME%\bin后保存。
【3】在D:\Program Files\mysql-5.7.18-winx64\bin下,新建文件my.ini,内容如下:

 [client] port=3306 #reset password option #skip-grant-table default-character-set=utf8 [mysqld]    bind-address = 127.0.0.1 port=3306 character_set_server=utf8 basedir  =%MYSQL_HOME%   datadir  =%MYSQL_HOME%\data tmpdir   =%MYSQL_HOME%\data  socket   =%MYSQL_HOME%\data\mysql.sock log-error=%MYSQL_HOME%\data\mysql_error.log max_connections=100 table_open_cache=256 query_cache_size=1M tmp_table_size=32M thread_cache_size=8 innodb_data_home_dir =%MYSQL_HOME%\data  innodb_flush_log_at_trx_commit =1 innodb_log_buffer_size=128M innodb_buffer_pool_size=128M innodb_log_file_size=10M innodb_thread_concurrency=16 innodb-autoextend-increment=1000 join_buffer_size = 128M sort_buffer_size = 32M read_rnd_buffer_size = 32M max_allowed_packet = 32M explicit_defaults_for_timestamp=true sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
 [WinMySQLAdmin] %MYSQL_HOME%\bin\mysqld.exe

【4】配置C:\WINDOWS\system32\drivers\etc\hosts,在19行附近,默认是注释掉的,去掉注释:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost 
【5】在D:\Program Files\mysql-5.7.18-winx64目录下新建data文件夹,必须为空 。
【6】点击鼠标进入D:\Program Files\mysql-5.7.18-winx64\bin目录下,按住Shift键同时鼠标右键弹出菜单,执行在此处打开命令窗口即可在目录下打开命令行窗口(注意:不在bin目录下安装和启动服务会产生错误),然后执行如下命令
mysqld --defaults-file=my.ini --initialize-insecure --user=mysql
mysqld --install

【7】启动mysql服务,如果没有启动的话,执行如下命令启动服务。
net start mysql
【8】设置数据库访问密码

方法一:使用mysqladmin命令

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.

方法二:
因为在上面第6步已经使用了--initialize-insecure选项,所以在第一次访问数据库是可以使用如下命令进入
mysql-u root --skip-password

mysql: [Warning] Using a password on the command line interface can be insecur
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
然后输入exit退出mysql。

mysql> exit
Bye

当然也可以通过如下方式设置密码

【9】测试数据库访问,在使用如下命令输入上面设置的密码,可以访问服务器了
mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>

【10】安装mysql数据库管理工具NavicatforMySQL

下载后的文件名称为:NavicatforMySQL.zip,绿色版,解压到D:\Program Files\Navicat for MySQL目录下,打开该目录下navicat.exe,然后新建连接按钮,在弹出的对话框中输入连接名称,主机名或者IP地址,端口号,用户名(root),密码(配置数据库设定的密码)。