微信搜索superit|邀请体验:大数据, 数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

mysql5和8的安装,windows为例

mysql aide_941 2℃ 0评论

单机步骤:

新建my.ini/my.cnf
mysqld -install
mysqld –initialize –console 记下初始密码
A temporary password is generated for root@localhost: 9T3TCtjbT=oP

mysql -u root -p

用navicat进去后会提示重设密码

root

输入以下命令来将MySQL注册为服务:
mysqld –install mysqlX
mysqld –install mysqlX –defaults-file=C:\path\to\your\my.ini

net start mysqlX
net stop mysqlX
删除服务
sc delete mysqlX

为MySQL 8.0及以上版本对安全性要求更高
MySQL的 8 版本以后,客户端用户连接的认证默认方式是 caching_sha2_password,而之前认证方式默认为 mysql_native_password
dbserver-》允许客户端使用公钥检索:编辑驱动,添加属性,jdbc 连接串中添加:allowPublicKeyRetrieval=true
或修改my.ini认证为 mysql_native_password-》default_authentication_plugin=mysql_native_password

授权
CREATE USER root@’%’ IDENTIFIED BY ‘root’;
grant all privileges ON . TO ‘root’@’%’ identified by ‘root’ with grant option; #8以前
grant all privileges on . to ‘root’@’%’ with grant option; #8以后
FLUSH PRIVILEGES;

CREATE USER root@’localhost’ IDENTIFIED BY ‘123456’;
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘密码’;
GRANT SELECT ON . TO root@’localhost’ identified by ‘root’;
GRANT SELECT ON databasename.tablename TO root@’localhost’ IDENTIFIED BY ‘123456’;
GRANT privileges ON databasename.tablename TO ‘username’@’host’
FLUSH PRIVILEGES;

下面是8和5版本的my.ini
———-5.7————

mysqld –install Mysql5

[mysqld]
port=3306
character_set_server=utf8
basedir=D:\Program Files\mysql-5.7.35-winx64
datadir=D:\Program Files\mysql-5.7.35-winx64\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

其他不重要的

server-id=1

lower_case_table_names=1

innodb_file_per_table = 1

log_timestamps=SYSTEM

log-error = error.log

slow_query_log = 1

slow_query_log_file = slow.log

long_query_time = 5

log-bin = binlog

binlog_format = row

expire_logs_days = 15

log_bin_trust_function_creators = 1

[client]
default-character-set=utf8

———-8———–

mysqld –install Mysql8

[mysqld]
port = 3306
basedir=D:\Program Files\mysql-8.0.11-winx64
datadir=D:\Program Files\mysql-8.0.11-winx64\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

5的默认default_authentication_plugin=mysql_native_password

8的采用新的默认default_authentication_plugin=caching_sha2_password

为了兼容老客户端

default_authentication_plugin=mysql_native_password

[mysql]
default-character-set=utf8

转载请注明:SuperIT » mysql5和8的安装,windows为例

喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!