安装MySQL

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
  1. vi /etc/my.cnf
  2. 在 [mysqld]最后加上 skip-grant-tables(手敲)
  3. service mysqld restart
  4. mysql -uroot -p 回车
  5. >use mysql;
  6. update user set authentication_string=password(‘密码’) where user=’root’;
  7. 修改回原来配置, 再次登陆后,再改一次密码
  8. 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;

Leave a Comment