1.ubuntu 中安装MySQL
sudo apt-get update
sudo apt-get install mysql-server
如安装失败,请尝试先执行: sudo apt-get -f install 再执行 sudo apt-get install mysql-server
编辑MySQL配置文件
vim /etc/mysql/my.cnf(有些版本在 /etc/mysql/mysql.conf.d/mysqld.cnf)
将
bind-address = 127.0.0.1
改为
bind-address = 0.0.0.0
2.用户管理
创建用户及授权
- 创建用户 student 密码为 123456,可以在任意地点登录
- 授予用户 student 在 ‘permission’ 数据库中拥有 SELECT 权限
CREATE USER 'student'@'%' IDENTIFIED BY '123456';
GRANT SELECT ON `permission`.* TO 'student'@'%';
(
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
flush privileges;
)
删除用户
DROP USER 'student'@'%';
查询用户
SELECT User`, Host, Password FROM `mysql`.`user`;
( SELECT User`, Host, authentication_string FROM `mysql`.`user`;)
网友评论