mysql安装部署
一.安装包准备
下载地址:
https://downloads.mysql.com/archives/community/
二.安装
1. 卸载mysql和mariadb相关
rpm -qa | grep mariadb
rpm -qa | grep mysql
rpm -e [查出来的包]
如果卸载不掉,可添加--nodeps参数
2. 安装mysql
rpm -ivh mysql-community-*
启动mysql
systemctl start mysqld
3. 查看mysql初始密码并修改密码
[root@dbserver mysql]# cat /var/log/mysqld.log | grep password
2022-04-20T08:31:02.259998Z 1 [Note] A temporary password is generated for root@localhost: ,SFV1kqQsQaf
[root@dbserver mysql]# mysql -uroot -p,SFV1kqQsQaf
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
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 global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
# 修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.01 sec)
# 开启远程连接
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
开启远程控制 :update user set host='%' where user='用户名';
取消远程控制:update user set host='localhost' where user='用户名';
删除用户 :delete from user where user="用户名" and host='host权限(localhost/%)';
设置显示某一个数据库的权限:grant all on 数据库名.* to 用户名;
4. 测试连接
每个人都在奋不顾身,都在加倍努力,得过且过只会让你和别人的差距越来越大...