♣安装mysql两种方法
♣下载mysql5.7解压版
♣配置步骤
♣解决服务无法启动
♣解决乱码
1.安装mysql两种方法
MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的。如果是msi格式的可以直接点击安装,按照它给出的安装提示进行安装,一般MySQL将会安装在C:Program FilesMySQLMySQL Server 5.7 该目录中;zip格式是自己解压,解压缩之后其实MySQL就可以使用了,但是要进行配置。
2.下载mysql5.7解压版
下载地址:https://dev.mysql.com/downloads/mysql/
我的安装路径是:E:dataBasemySqlmysql-5.7.12-winx64
配置环境变量:
我的电脑->属性->高级->环境变量 选择PATH,在其后面添加: 你的mysql bin文件夹的路径
;E:dataBasemySqlmysql-5.7.12-winx64in
3.配置步骤
3.1配置my.ini
把根目录下的my-default.ini 改名 为my.ini 。然后把里边的#号去掉,配置为(注意里边的路径要改为自己的安装路径):
1 # For advice on how to change settings please see 2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 3 # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the 4 # *** default location during install, and will be replaced if you 5 # *** upgrade to a newer version of MySQL. 6 7 [mysqld] 8 9 # Remove leading # and set to the amount of RAM for the most important data 10 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 11 # innodb_buffer_pool_size = 128M 12 13 # Remove leading # to turn on a very important data integrity option: logging 14 # changes to the binary log between backups. 15 # log_bin 16 17 # These are commonly set, remove the # and set as required. 18 basedir =E:dataBasemySqlmysql-5.7.12-winx64 19 datadir =E:dataBasemySqlmysql-5.7.12-winx64data 20 port =3306 21 character-set-server=utf8 22 # server_id = ..... 23 24 25 # Remove leading # to set options mainly useful for reporting servers. 26 # The server defaults are faster for transactions and fast SELECTs. 27 # Adjust sizes as needed, experiment to find the optimal values. 28 # join_buffer_size = 128M 29 # sort_buffer_size = 2M 30 # read_rnd_buffer_size = 2M 31 32 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%';