2019-03-23-初次使用mysql数据库安装,用户名和密码等问题

mysql问题

mysql安装

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
systemctl start mysqld.service
yum -y remove mysql57-community-release-el7-10.noarch

mysql初始密码查找

grep "password" /var/log/mysqld.log


修改初始密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

授予权限


mysql远程连接

问题:
ERROR 1130 (HY000): Host '223.87.33.93' is not allowed to connect to this MySQL server
解决办法:
update user set host = '%' where user = 'root';
flush privileges;


忘记密码处理:

  • vim /etc/my.cnf, 在mysqld增加skip-grant-tables
  • 重启mysql服务
  • 登陆mysql
  • 修改密码:
  1. use mysql;
  2. update user set authentication_string=password('root') where User='root';
  3. flush privileges;
  4. quit
  • 或者授权
    此处省略1000字
  • 删除skip-grant-tables配置
  • 重启mysql

你可能感兴趣的:(2019-03-23-初次使用mysql数据库安装,用户名和密码等问题)