MySQL的安装与配置
1.下载免安装版压缩包并直接解压即可 下载地址;
2.在安装目录下添加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.
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
port=3306
basedir ="D:\mysql-5.7.12-winx64/"
datadir ="D:\mysql-5.7.12-winx64/data/"
tmpdir ="D:\mysql-5.7.12-winx64/data/"
socket ="D:\mysql-5.7.12-winx64/data/mysql.sock"
log-error="D:\mysql-5.7.12-winx64/data/mysql_error.log"
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir="D:\mysql-5.7.12-winx64/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
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"
skip-grant-tables
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
####################配置文件结束###################
3.在windows系统环境变量path,加入如下内容
D:\mysql-5.7.12-winx64\bin;
原理:环境变量里面的path路径就是cmd系统的查找目录路径。设置了以后就不需要再切换cmd路径了。
4.以管理员身份运行cmd.exe,进入安装目录\bin,并安装MySQL服务,逐句输入:
D:
cd mysql-5.7.12-winx64
cd bin
mysqld install
注:卸载服务
net stop mysql
d:\mysql\bin\mysqld -remove
注:安装问题:“发生系统错误 193”
解决办法:D:\mysql-5.7.12-win64\bin 有个mysqld的空文件,删除即可。
5.初始化: mysqld --initialize
6.启动mysql:net start mysql
关闭mysql:net stop mysql
7.启动Mysql客户端程序,登陆MYSQL服务器:mysql -u root -p
--> 输入密码
8.在客户端程序上的操作:
(1)获取帮助:help
(2)获取服务器信息:\s
(3)查询字符集的设置
SHOW VARIABLES LIKE '%character_set_%'
(4)退出Mysql: \q
9.修改配置方式
直接修改my.ini即可。修改后需要重启MYSQL服务。
10.修改ROOT用户密码
先正常登陆MySQL服务器,然后逐句输入:
use mysql;
update user set password =password('新密码') where user='root' and host='localhost';
flush privileges;
\q
注意:
(1)如果原先登陆不需要密码,需要事先做如下操作:
use mysql;
select host,user,password from user;
(2)确定user表中没有password字段则继续:
alter table user add password char(41);
(3)flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。MySQL用户数据和权限有修改后,希望在"不重启MySQL服务"的情况下直接生效,那么就需要执行这个命令。
随心所欲不逾矩.