[root@izwz93zazliojetgsr3tymz ~]# yum list installed | grep mysql 或rpm -qa | grep mysql
移除已安装包
yum -y remove + 需移除包名
检查mysql组和用户是否存在,如无创建
[root@izwz93zazliojetgsr3tymz ~]# cat /etc/group | grep mysql
[root@izwz93zazliojetgsr3tymz ~]# cat /etc/passwd | grep mysql
创建mysql用户组
[root@izwz93zazliojetgsr3tymz ~]# groupadd mysql
创建一个用户名为mysql的用户并加入mysql用户组
[root@izwz93zazliojetgsr3tymz ~]# useradd -g mysql mysql
制定密码为123456
[root@izwz93zazliojetgsr3tymz ~]# passwd mysql
Changing password for user mysql.
New password: (注意:输入密码时是不可见的!)
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
安装到/usr/local (将下载好的安装包移进此目录下,解压)
[root@izwz93zazliojetgsr3tymzlocal]# tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
[root@izwz93zazliojetgsr3tymzlocal]# chown -R mysql mysql57/
[root@izwz93zazliojetgsr3tymzlocal]# chgrp -R mysql mysql57/
[root@izwz93zazliojetgsr3tymzlocal]# cd mysql57/
[root@izwz93zazliojetgsr3tymz mysql57]# mkdir data
[root@izwz93zazliojetgsr3tymz mysql57]# chown -R mysql:mysql data
[root@izwz93zaz1iojetgsr3tymz /]# mysql -uroot -p
Enter password:
Welcome tothe MySQL monitor. Commands endwith ; or \g.
Your MySQL connection idis4
Server version: 5.7.20
Copyright (c) 2000, 2017, Oracle and/orits affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/orits
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
添加远程访问权限
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host,user from user;
+-----------+-----------+| host | user |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
+-----------+-----------+
2 rows in set (0.00 sec)
# create user 'xxx'@'%' identified by '123'; 这里 @‘%’ 表示在任何主机都可以登录
mysql> quit;退出重启
[root@hdp265dnsnfs bin]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS!
StartingMySQL. SUCCESS!