- 检测是否安装
rpm -qa | grep mysql
- install
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
- 权限设置
chown mysql:mysql -R /var/lib/mysql
- 初始化 MySQL
mysqld --initialize
- 启动
systemctl start mysqld
- 查看 MySQL 运行状态
systemctl status mysqld
- 版本
mysqladmin --version
- 设置root
mysqladmin -u root password "new_password";
- 创建新用户
CREATE USER ‘Kevin'@'localhost' IDENTIFIED BY ‘123456';
- 验证创建是否成功
SELECT host, user, password FROM mysql.user WHERE user='Kevin';
- 赋予权限
GRANT<privileges>ON <database>.<table> TO 'Kevin'@'localhost';
ex: GRANT CREATE, INSERT ON *.* TO 'Kevin'@'localhost';
- 查看权限
SHOW GRANTS FOR 'Kevin'@'localhost';
- 移除权限
REVOKE <privileges> ON <database>.<table> FROM 'Kevin'@'localhost';
- 刷新
FLUSH PRIVILEGES;
- 查看是否启动
ps -ef | grep mysqld
- 启动
root@host# cd /usr/bin
./mysqld_safe &
- 关闭
root@host# cd /usr/bin
./mysqladmin -u root -p shutdown
- 创建数据库
CREATE DATABASE IF NOT EXISTS RUNOOB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
创建数据库,该命令的作用:
- 如果数据库不存在则创建,存在则不创建。
- 创建RUNOOB数据库,并设定编码集为utf8
网友评论