- linux环境下mysql的安装
- sudo yum install mysql-server
- 修改配置文件
- vim /etc/my.cnf
- 添加default-character-set = utf8
- 设置mysql随系统自动启动
- 检查设置是否正确
- sudo chkconfig --list mysqld
- mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- 2-5都是启动则ok
- 启动mysql
- sudo service mysqld start
- 如果出现错误 MySQL Daemon failed to start. 请参考
- 删除匿名用户
- select user,host from mysql.user;
- +------+--------------------+
- | user | host |
- +------+--------------------+
- | root | 127.0.0.1 |
- | | localhost |
- | root | localhost |
- | | vm\_24\_26\_centos |
- | root | vm\_24\_26\_centos |
- +------+--------------------+
- delete from mysql.user where user=‘‘;
- 刷新一下权限
- flush privileges;
- 在防火墙下面开放3306端口,开放给外网
- sudo vim /etc/sysconfig/iptables
- #mysql port
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
- 重启防火墙
- service iptables restart
- 重新登录mysql
- mysql -u root
- 创建一个非root权限的账户,避免使用root
- insert into mysql.user(Host,User,Password)values("localhost","mmall",password("mmall"));
- 检查插入是否正确
- select user,host from mysql.user;
- +-------+--------------------+
- | user | host |
- +-------+--------------------+
- | root | 127.0.0.1 |
- | mmall | localhost |
- | root | localhost |
- | root | vm\_24\_26\_centos |
- +-------+--------------------+
- 创建一个数据库
- create database `mmall` default character set utf8 collate utf8_general_ci;
- 查看权限
- select * from mysql.user \G
- 赋予权限
- 切换数据库 use mmall;
- grant all privileges on mmall.* to mmall@‘%‘ identified by ‘mmall‘ with grant option;
- 注意,此语句可能有错误,导致执行下面的权限查询的时候出现授权不起作用的现象,可以改为下面的授权语句。
- grant all privileges on *.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
- 请参看
- https://bbs.csdn.net/topics/330154879
- 可以更细化权限为
- grant select,delete,create on mmall.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
- 重新查看全新
- select * from mysql.user \G
- 修改root账号的密码
- set password for [email protected]=password(‘root‘);
- set password for [email protected]=password(‘root‘);
- select user,host,password from mysql.user;
- 退出重新登录
- 使用密码登录,否则没有权限
- win下安装mysql
- 略
7mysql的配置和安装
Posted sunnyangzs
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了7mysql的配置和安装相关的知识,希望对你有一定的参考价值。
以上是关于7mysql的配置和安装的主要内容,如果未能解决你的问题,请参考以下文章