一、解压mysql-5.7.17-rc-winx32.zip 到特定位置,例如C:\Program Files
二、赋值my-default.ini 为 my.ini
三、修改my.ini
[client]
default-character-set=utf8
[mysqld]
# Remove leading # and set to the amount of RAM for the mostimportant data # cache in MySQL. Start at 70% of total RAM for dedicated server,else 10%. # innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrityoption: logging # changes to the binary log between backups. # log_bin
# These are commonly set, remove the # and set asrequired. basedir = "C:\Program Files\mysql-5.7.17" datadir = "C:\Program Files\mysql-5.7.17\data" tmpdir = "C:\Program Files\mysql-5.7.17\data" socket = "C:\Program Files\mysql-5.7.17\data\mysql.sock" port = 3306
log-error = "C:\ProgramFiles\mysql-5.7.17\data\mysql_error.log"
# server_id = .....
max_connections = 100 table_open_cache = 256 query_cache_size = 1M
tmp_table_size = 32M thread_cache_size = 8
innodb_data_home_dir = "C:\ProgramFiles\mysql-5.7.17\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
# Remove leading # to set options mainly useful for reportingservers. # The server defaults are faster for transactions and fastSELECTs. # Adjust sizes as needed, experiment to find the optimalvalues. 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"
四、配置环境变量,即将"C:\ProgramFiles\mysql-5.7.17\bin"添加到path中(注意变量之间用“;”隔开);
五、添加服务:打开cmd命令模式,切换到目录"C:\ProgramFiles\mysql-5.7.17\bin"执行mysqld -install mysql57(可配,默认为mysql) 删除使用 mysqld -remove mysql157
六、初始化data 新建data文件夹,然后用命令初始化 mysqld --initialize 先初始化data目录
七、启动服务:在cmd命令模式下,输入net start mysql57,数据库即可启动。
七、修改root密码
第一次修改(忘记密码也可使用此方法)不知道初始密码,需要先将服务停止,然后打开一个cmd输入以下命令: mysqld --defaults-file="C:\ProgramFiles\mysql-5.7.17\my.ini" --console --skip-grant-tables 再打开另一个cmd
命令行执行:mysql –u root -p;,直接回车,不输入密码
mysql>show databases;
mysql>use mysql;
mysql> SET password=PASSWORD('123456');
上句不行,则使用: mysql> update user set password=password(“123”) whereuser=“root”;
仍然不行,则使用: mysql>update user set authentication_string=password("123456")where user="root";
mysql> flush privileges; #更新权限
mysql> quit
八、mysql远程授权
mysql -u root -p Enter password:
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> 或者:
grant all on *.* to 'root'@'%'identified by '123456'; 如果不设置远程连接,用mysql数据库连接工具可是连接不上的哦!!!
若是出现错误: ERROR 1820 (HY000): You must reset your password using ALTER USERstatement before executing this statement.
重设一下密码即可: mysql> set password=password('123456')
然后再启用远程授权: mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
14.用数据库连接工具来测试你刚刚的安装是不是成功了,可以使用 DBeaver 或者Navicat 或者 DB Tool Manager
首先要知道,远程连接的Linux系统的ip,确保本机已经能够ping通的情况下再连接。