8 安装MySQL
cd ~
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm rpm -ivh mysql57-community-release-el7-9.noarch.rpm cd /etc/yum.repos.d/
yum install mysql-server
#启动
systemctl enable mysqld
systemctl start mysqld
- vi /etc/my.cnf
- 在 [mysqld]最后加上 skip-grant-tables(手敲)
- service mysqld restart
- mysql -uroot -p 回车
- >use mysql;
- update user set authentication_string=password(‘密码’) where user=’root’;
- 修改回原来配置, 再次登陆后,再改一次密码
- mysql -uroot -p我的密码
alter user user() identified by ‘密码’;
开放局域网访问:
use mysql;
update user set host =’%’ where user = ‘root’;
flush privileges;
select host,user from user;
#mysql 开只读账号
GRANT ALL PRIVILEGES ON *.* TO “root”@”localhost” IDENTIFIED BY “密码” WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO “root”@”192.168.0.204” IDENTIFIED BY “密码” WITH GRANT OPTION;
flush privileges;
GRANT Select ON 数据库名.* TO reader@”%” IDENTIFIED BY “只读密码”; –只有select 权限
添加远程ip访问权限
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’10.10.10.10’ IDENTIFIED BY ‘密码’ WITH GRANT OPTION;
flush privileges;