当前位置:网站首页>mysql使用笔记一
mysql使用笔记一
2022-07-07 15:33:00 【python与大数据分析】
MySQL和postgresql是目前比较火的两大开源数据库,绝大多数国产数据库都衍生于此,MySQL从整个架构上、设计上和语法上讲类似于早期的Sybase,SQLServer也源之于Sybase,从应用上讲SQLServer更友好,功能更丰富,单体数据库性能也是最好的;MySQL还有诸多的限制,不过这里只是试验和笔记,不做赘述。
1、第一次登陆MySQL,需要从日志从获取初始密码
[[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、各项操作前需要先更新初始密码,再修改符合需要的密码策略
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、进入数据,修改用户表,确保外部用户可以访问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、给root用户外部用户赋权
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、修改配置文件,绑定IP地址,再修改防火墙,确保外部用户能访问端口
[[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]#
最后,谢谢关注,谢谢支持!
边栏推荐
- Cesium (4): the reason why gltf model is very dark after loading
- 打造All-in-One应用开发平台,轻流树立无代码行业标杆
- Skimage learning (1)
- QT视频传输
- DAPP defi NFT LP single and dual currency liquidity mining system development details and source code
- 【PHP】PHP接口继承及接口多继承原理与实现方法
- Ray and OBB intersection detection
- skimage学习(2)——RGB转灰度、RGB 转 HSV、直方图匹配
- LeetCode 300. 最长递增子序列 每日一题
- QML初学
猜你喜欢
二叉搜索树(基操篇)
最新2022年Android大厂面试经验,安卓View+Handler+Binder
【MySql进阶】索引详解(一):索引数据页结构
Horizontal and vertical centering method and compatibility
node:504报错
Pisa-Proxy SQL 解析之 Lex & Yacc
Master this promotion path and share interview materials
正在准备面试,分享面经
Reflections on "product managers must read: five classic innovative thinking models"
最新高频Android面试题目分享,带你一起探究Android事件分发机制
随机推荐
二叉搜索树(基操篇)
Opencv configuration 2019vs
QT视频传输
Sqlserver2014+: create indexes while creating tables
运算符
Talk about the realization of authority control and transaction record function of SAP system
LeetCode 120. Triangle minimum path and daily question
LeetCode 1696. Jumping game VI daily question
[designmode] proxy pattern
skimage学习(3)——Gamma 和 log对比度调整、直方图均衡、为灰度图像着色
LeetCode 213. Home raiding II daily question
数据中台落地实施之法
ATM系统
【视频/音频数据处理】上海道宁为您带来Elecard下载、试用、教程
The process of creating custom controls in QT to encapsulating them into toolbars (II): encapsulating custom controls into toolbars
C语言进阶——函数指针
OpenGL personal notes
Number of exchanges in the 9th Blue Bridge Cup finals
node:504报错
LeetCode 1696. 跳跃游戏 VI 每日一题