当前位置:网站首页>MySQL usage notes 1
MySQL usage notes 1
2022-07-07 17:08:00 【Python and big data analysis】
MySQL and postgresql It is currently the two popular open source databases , Most domestic databases are derived from this ,MySQL From the whole architecture 、 It is similar in design and grammar to the early Sybase,SQLServer Also derived from Sybase, In terms of application SQLServer More friendly , More features , The performance of a single database is also the best ;MySQL There are also many limitations , But here are just experiments and notes , Do not go into .
1、 First landing MySQL, You need to get the initial password from the log
[[email protected] local]# grep 'temporary password' /var/log/mysqld.log
-06-16T04::36.398736Z [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: oyazXUIps8)F
[[email protected] local]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 8.0.29
Copyright (c) , , Oracle and/or its affiliates.
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.
2、 The initial password needs to be updated before each operation , Then modify the password policy that meets the needs
mysql> SHOW VARIABLES LIKE 'validate_password.%';
ERROR (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[email protected]';
ERROR (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1qaz!QAZ';
Query OK, rows affected (0.01 sec)
mysql> SHOW VARIABLES LIKE 'validate_password.%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | |
| validate_password.mixed_case_count | |
| validate_password.number_count | |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | |
+--------------------------------------+--------+
rows in set (0.02 sec)
mysql> set global validate_password.length=;
Query OK, rows affected (0.00 sec)
mysql> set global validate_password.policy=;
Query OK, rows affected (0.00 sec)
mysql> set global validate_password.check_user_name=off;
Query OK, rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password.%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | OFF |
| validate_password.dictionary_file | |
| validate_password.length | |
| validate_password.mixed_case_count | |
| validate_password.number_count | |
| validate_password.policy | LOW |
| validate_password.special_char_count | |
+--------------------------------------+-------+
rows in set (0.01 sec)
3、 Enter the data , Modify the user table , Ensure that external users can access MySQL
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> select host,user from user where user='root';
+-----------+------+
| host | user |
+-----------+------+
| localhost | root |
+-----------+------+
row in set (0.00 sec)
mysql> update user set host='%' where user='root';
Query OK, row affected (0.01 sec)
Rows matched: Changed: Warnings:
mysql> select host,user from user where user='root';
+------+------+
| host | user |
+------+------+
| % | root |
+------+------+
row in set (0.00 sec)
4、 to root User external user empowerment
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
ERROR (): You are not allowed to create a user with GRANT
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.01 sec)
mysql>
5、 Modify the configuration file , binding IP Address , Modify firewall again , Ensure that external users can access the port
[[email protected] local]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp ...: ...:* LISTEN /sshd
tcp 127.0..: ...:* LISTEN /master
tcp 192.168.13.50: 123.123.123.2: ESTABLISHED /sshd: [email protected]
tcp 192.168.13.50: 192.168.13.11: ESTABLISHED /sshd: [email protected]
tcp 192.168.13.50: 123.123.123.2: ESTABLISHED /sshd: [email protected]
tcp6 ::: :::* LISTEN /mysqld
tcp6 ::: :::* LISTEN /sshd
tcp6 ::: :::* LISTEN /master
tcp6 ::: :::* LISTEN /mysqld
pid-file=/var/run/mysqld/mysqld.pid
[[email protected] local]# vi /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
bind-address=...
"/etc/my.cnf" L, C written
[[email protected] local]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[[email protected] local]# firewall-cmd --reload
success
[[email protected] local]#
Last , Thank you for your attention , Thank you for your support !
边栏推荐
- LeetCode 1186. Delete once to get the sub array maximum and daily question
- LeetCode 1986. 完成任务的最少工作时间段 每日一题
- LeetCode 1981. 最小化目标值与所选元素的差 每日一题
- 科普达人丨一文弄懂什么是云计算?
- Test case management tool recommendation
- ByteDance Android gold, silver and four analysis, Android interview question app
- 服务器彻底坏了,无法修复,如何利用备份无损恢复成虚拟机?
- 一文读懂数仓中的pg_stat
- LeetCode 1654. 到家的最少跳跃次数 每日一题
- skimage学习(2)——RGB转灰度、RGB 转 HSV、直方图匹配
猜你喜欢
A tour of gRPC:03 - proto序列化/反序列化
Skimage learning (3) -- adapt the gray filter to RGB images, separate colors by immunohistochemical staining, and filter the maximum value of the region
浅浅理解.net core的路由
Pisa-Proxy SQL 解析之 Lex & Yacc
字节跳动Android金三银四解析,android面试题app
PLC:自动纠正数据集噪声,来洗洗数据集吧 | ICLR 2021 Spotlight
skimage学习(1)
Lowcode: four ways to help transportation companies enhance supply chain management
字节跳动高工面试,轻松入门flutter
整理几个重要的Android知识,高级Android开发面试题
随机推荐
Lowcode: four ways to help transportation companies enhance supply chain management
Localstorage and sessionstorage
正在准备面试,分享面经
LeetCode 213. Home raiding II daily question
最新Android面试合集,android视频提取音频
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
ByteDance Android gold, silver and four analysis, Android interview question app
LeetCode 1477. Find two subarrays with sum as the target value and no overlap
os、sys、random标准库主要功能
typescript ts基础知识之tsconfig.json配置选项
LeetCode 1986. The minimum working time to complete the task is one question per day
Temperature sensor chip used in temperature detector
Test case management tool recommendation
最新阿里P7技术体系,妈妈再也不用担心我找工作了
centos7安装mysql笔记
LeetCode 1654. The minimum number of jumps to get home one question per day
低代码(lowcode)帮助运输公司增强供应链管理的4种方式
LeetCode 1031. 两个非重叠子数组的最大和 每日一题
【图像传感器】相关双采样CDS
谎牛计数(春季每日一题 53)