数据库Mysql安装和配置

5 数据库mysql

关系型数据库管理系统,分为社区版免费和商业版,体积小数度快,总体成本低,开放源码,一般中小型网站的开发都选择MYSQL作为网站数据库。

5.1 下载地址:选择MySQL Community Server社区版下载,建议下载安装版.msi

社区版:https://dev.mysql.com/downloads/mysql/

直达地址:https://dev.mysql.com/downloads/windows/installer/8.0.html

https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.19.0.msi

5.2 安装

基本都是下一步标准配置就好,配置root数据库密码,远程权限一般不给root用户开,比较危险,最好安装好后要记住mysql安装的目录,后续可能要更改mysq的my.ini配置文件

数据库Mysql安装和配置

5.3 配置字符集-utf-8,防止中文乱码

找到mysql安装目录中的my.ini文件,查找default-character-set和character-set-server节点,修改成utf8

数据库Mysql安装和配置

 

数据库Mysql安装和配置

5.4 mysql基本操作

a 查看目前mysql用户:select user,host,password from mysql.user

b 修改root密码:set password for [email protected]=password('your_set_password')

c 命令登录mysql: mysql -u root -p

d 查看是否有匿名数据库用户(即用户名为空的): select user,host from mysql.user

e 删除匿名用户:delete from mysql.user where user=''

f 插入mysql用户:insert into mysql.user(Host,User,Password) values ("localhost","newusername",password("yourpassword"));

g 使操作生效:flush privileges

h 给帐号所有权限:grant all privileges on yourdatabase.* to [email protected] identified by "yourpassword"

i 给帐号部分权限:grant select,insert,update on yourdatabase.* to [email protected] identified by "yourpassword"

grant select,insert,update on yourdatabase.a_table_name to [email protected] identified by "yourpassword" (给数据中的某个表的某个人的权限)

 

数据库管理工具:推荐适用Navicat for MYSQL