Linux安装Mysql rpm
1.安装时候会提示与已经安装的RPM包有冲突,所以我们先卸载一些RPM包,要卸载哪些呢?我们要卸载的是包含有mariadb关键字的RPM包,执行命令:rpm -qa|grep mariadb来查看一下我们要卸载哪些软件,看下图:
2.既然知道了是哪些RPM包,就开始卸载吧!执行命令:
rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
rpm -e --nodeps mariadb-server-5.5.41-2.el7_0.x86_64
rpm -e --nodeps mariadb-5.5.41-2.el7_0.x86_64
3.虽然官方文档说安装mysql-community-client-5.7.9-1.el7.x86_64.rpm和mysql-community-server-5.7.9-1.el7.x86_64.rpm就可以获得标准功能的MySQL。但是由于RPM包的依赖关系,所以实际上我们还要多装2个RPM包:mysql-community-common-5.7.9-1.el7.x86_64.rpm和mysql-community-libs-5.7.9-1.el7.x86_64.rpm。依次执行命令:
rpm -ivh mysql-community-common-5.7.9-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.9-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.9-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.9-1.el7.x86_64.rpm
4.Mysql数据库的root账户会产生一个随机初始密码,执行命令:
vi /var/log/mysqld.log
5.现在可以启动mysqld服务了,执行命令:
systemctl start mysqld.service
systemctl status mysqld.service
6.登录mysql并修改root用户密码,执行命令:
mysql -uroot -p
alter user 'root'@'localhost' identified by 'root';
grant all privileges on *.* to '用户名'@'IP' identified by '密码' with grant option;
7.修改root用户密码
update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
flush privileges;
8备份数据库命令:mysqldump -uroot -p -h192.168.0.19 ide_web > D:\mytest.sql
9.新增超级权限并允许远程访问:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
10.更改mysql编码方式,执行命令vim /etc/my.cnf,增加下面记录:
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci