1、安装mysql
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql-server
2、修改配置文件
vi /etc/my.cnf
可以修改数据存储的位置,datadir=/var/lib/mysql
可以添加skip-grant-tables 跳过输入密码
3、启动
启动:service mysqld start
停止:service mysqld stop
重启:service mysqld restart
4、登录
通过命令 grep "password" /var/log/mysqld.log 找到随机生成的密码
通过mysql -u root -p登录
通过alter user 'root'@'localhost' identified by '123456'修改密码
通过flush privileges 保存
5、授权远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION
flush privileges
6、创建普通用户
create user "test"@"%" identified by "password";
grant all privileges on `test`.* to 'test'@'%' ;
7、卸载mysql
通过rpm -qa | grep -i mysql查看安装情况
[root@wcz usr]# rpm -qa|grep -i mysql
mysql-community-client-5.7.27-1.el7.x86_64
mysql-community-common-5.7.27-1.el7.x86_64
mysql57-community-release-el7-8.noarch
mysql-community-libs-5.7.27-1.el7.x86_64
mysql-community-server-5.7.27-1.el7.x86_64
mysql-community-libs-compat-5.7.27-1.el7.x86_64
依次卸载
rpm -ev mysql-community-server-5.7.27-1.el7.x86_64
rpm -ev mysql57-community-release-el7-8.noarch
rpm -ev mysql-community-client-5.7.27-1.el7.x86_64