centos7.3安装mysql
1.检测是否已经安装mysql服务
rpm -qa | grep mysql
2.下载mysql包
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
3. 安装 mysql57-community-release-el7-8.noarch.rpm:
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
4.下载安装mysql
yum install mysql-server
5.启动mysql服务
service mysqld start
6.查看随机密码
grep "password" /var/log/mysqld.log
2019-05-14T02:17:16.818716Z 1 [Note] A temporary password is generated for root@localhost: Eal>tvRy(8?n
7.进入mysql命令模式修改密码
mysql -uroot -"Eal>tvRy(8?n"
8.使用随机密码连接mysql
/usr/bin/mysql -u root -p
Eal>tvRy(8?n
9.修改密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Peng136143.');
如果出现这个错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
那是因为密码设置得太简单了
10.停止服务
service mysqld stop
11.heidisql连接mysql
报错:Host isnot allowed to connect to this mysql server
use mysql
update user set host = '%' where user ='root';
FLUSH PRIVILEGES
执行即可,报错也没关系。再次连接成功