1、adduser -g mysql mysql,尽量用这个用户,会省掉一些坑;
2、下载mysql-5.7.12-1.el7.x86_64.rpm-bundle.tar,会解压出12个rpm;
3、要卸载的是包含有mariadb关键字的RPM包,执行命令:rpm -qa|grep mariadb,查看一下我们要卸载哪些软件;
卸载:rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64;
4、进入tar解压目录,依次安装4个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
5、初始化,赋予文件夹mysql用户权限:bin/mysqld --initialize --user=mysql,如果找不到mysqld,进sbin看看;
6、查看/var/log/mysqld.log,搜password关键字,即root用户的密码;
7、root用户启动mysql:systemctl start mysqld;通过ps -elf|grep mysqld可以看到进程启动用户为mysql;
8、查看mysql状态:systemctl status mysqld;
9、登录mysql:mysql -u root -p;
10、更改用户密码:alter user 'root'@'localhost' identified by 'newpassword';
over
********************************************************************************
卸载mysql
1、yum remove mysql mysql-server mysql-libs compat-mysql151;
2、rm -rf /var/lib/mysql;
3、rm -rf /etc/my.cnf;
4、查看是否还有mysql:rpm -qa|grep mysql,
有就继续卸载:rpm -e --nodeps mysql...;
********************************************************************************
1、创建用户
create user 'appMysql' identified by '&D%E$Ma8.9p23';
2、所有远程机器都可以登录,并给指定表数据库赋权
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'appMysql'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
3、指定远程机器都可以登录,并给指定表数据库赋权
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'appMysql'@'i' IDENTIFIED BY 'password' WITH GRANT OPTION;p
4、刷新全新
flush privileges;
5、删除用户
drop user 'appMysql'@'%';