♣安装mysql两种方法
♣下载mysql5.7解压版
♣配置步骤
♣解决服务无法启动
♣解决乱码
1.安装mysql两种方法
MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的。如果是msi格式的可以直接点击安装,按照它给出的安装提示进行安装,一般MySQL将会安装在C:\Program Files\MySQL\MySQL Server 5.7 该目录中;zip格式是自己解压,解压缩之后其实MySQL就可以使用了,但是要进行配置。
2.下载mysql5.7解压版
下载地址:https://dev.mysql.com/downloads/mysql/
我的安装路径是:E:\dataBase\mySql\mysql-5.7.12-winx64
配置环境变量:
我的电脑->属性->高级->环境变量 选择PATH,在其后面添加: 你的mysql bin文件夹的路径
;E:\dataBase\mySql\mysql-5.7.12-winx64\bin
3.配置步骤
.1配置my.ini
把根目录下的my-default.ini 改名 为my.ini 。然后把里边的#号去掉,配置为(注意里边的路径要改为自己的安装路径):
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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. [mysqld] # 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 =E:\dataBase\mySql\mysql-5.7.12-winx64
datadir =E:\dataBase\mySql\mysql-5.7.12-winx64\data
port =3306
character-set-server=utf8
# 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 = 2M
# read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
3.2新建data文件夹
mysql5.7.12下建data文件夹,记得data每次都要把里边的内容清空掉(data文件夹其实就是用来放数据库的)。然后执行初使化命令:
mysqld --initialize --user=mysql --console
运行结果:先执行以上命令, 生成库. 注意有个临时密码(我的为XUBGAiu+x7ak), 要记下来。
接下来启动服务,命令行为:net start mysql
然后再命令行: mysql -u root -p
输入密码 (上面给的临时密码), 登录成功。
接下来输入新密码:set password=password('0821'); 在这里,0821为我的新密码
退出登录:mysql > exit;
停止mysql服务:net stop mysql
注意:输入查询语句要以分号结束。比如,修改密码的时候,语句后面要有分号,不然会出现
mysql>set password = password('root')
->
->
->
一直到你输入分号为止。
4.解决服务无法启动
5.解决乱码
MySQL的默认编码是Latin1,不支持中文.
输入查询语句:
show variables like '%character%';