rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
rpm -Uvh http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
yum -y install mysql-community-server
# 启动mysql
systemctl start mysqld
# 设置开机启动
systemctl enable mysqld
# 查看mysql状态
systemctl status mysqld
使用命令
grep "temporary password" /var/log/mysqld.log
mysql -u用户名 -p密码
# 因为有特殊符号,所以加了引号
alter user "root"@"localhost" identified by "123456Abcd+-";
# 设置密码等级
mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)
# 设置密码长度
mysql> set global validate_password_length=6;
Query OK, 0 rows affected (0.00 sec)
# 修改用户密码
mysql> alter user "root"@"localhost" identified by "123456";
Query OK, 0 rows affected (0.00 sec)
# % 表示任意远程地址
# 这里的 % 可以指定为某一个地址 例如 192.168.1.1
mysql> grant all privileges on *.* to "root"@"%" identified by "123456" with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
# 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
rpm -Uvh http://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
yum -y install mysql-community-server
# 启动mysql
systemctl start mysqld
# 设置开机启动
systemctl enable mysqld
# 查看mysql状态
systemctl status mysqld
使用命令
grep "temporary password" /var/log/mysqld.log
mysql -u用户名 -p密码
# 因为有特殊符号,所以加了引号
alter user "root"@"localhost" identified with mysql_native_password by "123456Abcd+-";
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user "root"@"localhost" identified with mysql_native_password by "123456";
Query OK, 0 rows affected (0.01 sec)
# % 表示任意远程地址
# 这里的 % 可以指定为某一个地址 例如 192.168.1.1
create user "root"@"%" identified with mysql_native_password by "123456";