yum search mysql
sudo yum remove mariadb-libs.x86_64
tmp下
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm
sudo yum install mysql-community-server
sudo service mysqld start/restart/stop/
cat /var/log/mysqld.log|grep password
密码:&#g,MU8vc!
YqKD0*eLh3ys
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
重置密码
SET PASSWORD = PASSWORD(‘123456’);
mysql -uroot -p
&#g,MU8vc!
远程
MySQL -h127.0.0.1 -uroot -p
use mysql;
show tables;
select Host,User from user \G;
update user set host=’%’ where Host = “localhost” and User = “root”;
flush privileges;
set global general_log_file=”/tmp/general.log”;
set global genenral_log=on;
set global validate_password_policy=0;
set global validate_password_length=1;
create user ‘imooc’@’%’ identified by ‘123456’;
赋予权限
grant all privileges on . to ‘imooc’@’%’ identified by ‘123456’ with grant option;
部分权限
grant select,insert,update, delete on . to ‘imooc’@’%’ identified by ‘123456’ with grant option;
flush privileges;
回收权限
revoke all privileges on . from imooc;
flush privileges;
修改root密码:
sudo vim /etc/my.cnf
在最后添加一行(跳过授权表的验证)
skip-grant-tables
重启服务
sudo service mysqld restart
不用输入密码就能进入数据库了
use mysql;
update user set authentication_string=password(‘456789’) where user=’root’;
flush privileges;
sudo vim /etc/my.cnf
去掉最后添加一行(跳过授权表的验证)
skip-grant-tables
重启服务
sudo service mysqld restart