安装mysql服务
版本:mysql-8.0.15-winx64
- 下载并安装mysql-8.0.15-winx64
- 系统环境配置
(1)添加变量名MYSQL_HOME,变量值为mysql的安装路径
(2)在变量名为parh下,添加值%MYSQL_HOME%bin
- 在bin下的目录文件中添加my.ini文件,需要basedir和datadir的值
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8
collation-server = utf8_bin
init_connect='SET NAMES utf8'
# Remove leading # and set to the amount of RAM for the most important 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 integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = H:\mysql-8.0.15-winx64
datadir = H:\mysql-8.0.15-winx64\data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
以下参考:服务无法启动解决链接
-
通过终端开启mysql服务。
(1)打开安装路径下的bin文件,在地址栏输入cmd后回车,即可进入该目录下的终端。
(2)输入mysqld --initialize-insecure后回车
等待一段时间后,在该路径下会生成一个data文件夹。data文件夹里面有一个以计算机用户命名、后缀为.err的文件,通过记事本打开,里面会有数据库用户的密码。(我生成的用户是没有密码的,这个在后面会用到)
(3)输入mysqld -install后回车,返回Service successfully installed.
(4)然后即可启动服务。输入net start mysql后回车
-
此时打开Navicat Premium12客户端,创建连接,报错
这是因为MySQL新版本(8以上版本)的用户登录账户加密方式是【caching_sha2_password】,Navicat不支持这种用户登录账户加密方式。
此时需要修改用户登录密码的加密方式。修改方式如下:
参考:修改加密方式链接(1)在对应路径下输入mysql -u root -p,即可切换到mysql。这里的密码参考data文件夹下,后缀为.err的文件
(2)输入select host,user,plugin from mysql.user;并回车。
(3)将原本的空密码设置为root,并改变其加密方式。
(4)检查一下是否修改成功。
这样即可成功在Navicat Premium12上成功连接上了。
外加一个增加用户的语句: