linux安装mysql5.6
2021-04-25
1、先检查系统是否安装有mysql
yum list installed | grep mysql
rpm –qa|grep mysql*
2、下载mysql安装包装
# 下载noarch.rpm wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # 这个rpm还不是mysql的安装文件,只是两个yum源文件,执行后,在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo rpm -ivh mysql-community-release-el7-5.noarch.rpm
用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件
[root@VM-0-11-centos local]# yum repolist all | grep mysql mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 194 mysql-connectors-community-source MySQL Connectors Community disabled mysql-tools-community/x86_64 MySQL Tools Community enabled: 126 mysql-tools-community-source MySQL Tools Community - Sou disabled mysql55-community/x86_64 MySQL 5.5 Community Server disabled mysql55-community-source MySQL 5.5 Community Server disabled mysql56-community/x86_64 MySQL 5.6 Community Server enabled: 581 mysql56-community-source MySQL 5.6 Community Server disabled mysql57-community-dmr/x86_64 MySQL 5.7 Community Server disabled mysql57-community-dmr-source MySQL 5.7 Community Server disabled
3 安装mysql服务
yum install mysql-community-server -y
4 启动mysql服务
# 设置开机启动
systemctl enable mysqld
# 启动mysql
systemctl start mysqld
5 允许远程访问
UPDATE user SET `Host` = ‘%‘ WHERE `User` = ‘root‘ LIMIT 1;
6 修改密码
mysql5.6 初始密码为空,用mysql -uroot进入mysql添加密码
use mysql; update user set password=password("密码") where user="root"; flush privileges;
若忘了密码
vi /etc/my.cnf, 在[mysqld]加
skip-grant-tables
重启mysql服务
systemctl restart mysqld
再执行上面的修改密码语句,再修改my.conf,重启服务即可
设置远程访问
UPDATE user SET `Host` = ‘%‘ WHERE `User` = ‘root‘ LIMIT 1;
查看User
select host,user,plugin from user;
mysql> select host,user,plugin from user; +----------------+------+-----------------------+ | host | user | plugin | +----------------+------+-----------------------+ | % | root | mysql_native_password | | vm-0-11-centos | root | mysql_native_password | | 127.0.0.1 | root | mysql_native_password | | ::1 | root | mysql_native_password | | localhost | root | mysql_native_password | | vm-0-11-centos | | mysql_native_password | +----------------+------+-----------------------+ 6 rows in set (0.00 sec)
7 mysql SELECT/UPDATE command denied to user ‘root‘@‘localhost‘ for table ‘XXX‘ 报错1142处理
8 navicat 出现 access denied for user root 错误解决办法
参考