我有一个日期,我想在 Typescript 中获取该日期的月份和年份。例如:如果我有 2024 年 7 月 1 日星期一,我的代码必须返回 2024 年 7 月。您能帮帮我吗?
我有一个日期,我想在 Typescript 中获取该日期的月份和年份。
例如:
如果我有 2024 年 7 月 1 日 ,我的代码必须是 return juil 2024 .
你能帮我吗?
我正在尝试使用 Ansible 为带有 MariaDB 的 Wordpress 创建环境,但是在尝试创建数据库和创建具有 O 权限的新用户时遇到了几乎相同的错误...
我正在尝试使用 Ansible 为带有 MariaDB 的 Wordpress 创建环境,但是在尝试创建数据库和在 Oracle Linux (9.4) 或 Fedora (40) 上创建具有权限的新用户时遇到了几乎相同的错误。
库存如下:
[fedora]
192.168.1.200 ansible_ssh_user=leo hostname=fedorasrv01
[oracle]
192.168.1.202 ansible_ssh_user=leo hostname=oraclesrv01
这是 ansible 剧本:
- name: Install Mariadb Server - RedHat
yum:
name:
- mariadb-server
- python3-pip
state: present
when: (ansible_facts['os_family'] == "RedHat")
- name: Install PyMySQL on RedHat
ansible.builtin.pip:
name: PyMySQL
state: present
when: (ansible_facts['os_family'] == "RedHat")
- name: "Start MariaDB"
service:
name: mariadb
state: started
enabled: yes
- name: Creating a database to be used by WordPress - RedHat
mysql_db:
name: "{{ db_wp_name }}"
state: present
when: (ansible_facts['os_family'] == "RedHat")
- name: Create user with password, all database privileges - RedHat
mysql_user:
name: "{{ db_wp_username }}"
password: "{{ db_wp_password }}"
priv: "{{ db_wp_name }}.*:ALL,GRANT"
state: present
when: (ansible_facts['os_family'] == "RedHat")
这些是错误:
TASK [mysql : Creating a database to be used by WordPress - RedHat] ***************************************************************************************************************************************************************************
fatal: [192.168.1.202]: FAILED! => {"changed": false, "msg": "unable to find /root/.my.cnf. Exception message: (1698, \"Access denied for user 'root'@'localhost'\")"}
fatal: [192.168.1.200]: FAILED! => {"changed": false, "msg": "unable to find /root/.my.cnf. Exception message: (1045, \"Access denied for user 'root'@'localhost' (using password: NO)\")"}
在寻找过程中,我尝试使用另一个 yml 来帮助,并在破坏管道的步骤之前调用它。
- name: Stop MySQL
service: name=mysqld state=stopped
- name: set environment variables
shell: systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
- name: Start MySQL
service: name=mysqld state=started
- name: sql query
command: mysql -u root --execute="UPDATE mysql.user SET authentication_string = PASSWORD('{{ mysql_root_password }}') WHERE User = 'root' AND Host = 'localhost';"
- name: sql query flush
command: mysql -u root --execute="FLUSH PRIVILEGES"
- name: Stop MySQL
service: name=mysqld state=stopped
- name: unset environment variables
shell: systemctl unset-environment MYSQLD_OPTS
- name: Start MySQL
service: name=mysqld state=started
但在此之后,现在的错误是:
TASK [mysql : sql query] **********************************************************************************************************************************************************************************************************************
fatal: [192.168.1.200]: FAILED! => {"changed": true, "cmd": ["mysql", "-u", "root", "--execute=UPDATE mysql.user SET authentication_string = PASSWORD('Password123') WHERE User = 'root' AND Host = 'localhost';"], "delta": "0:00:00.087770", "end": "2024-07-02 07:06:47.621171", "msg": "non-zero return code", "rc": 1, "start": "2024-07-02 07:06:47.533401", "stderr": "ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable", "stderr_lines": ["ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable"], "stdout": "", "stdout_lines": []}
fatal: [192.168.1.202]: FAILED! => {"changed": true, "cmd": ["mysql", "-u", "root", "--execute=UPDATE mysql.user SET authentication_string = PASSWORD('Password123') WHERE User = 'root' AND Host = 'localhost';"], "delta": "0:00:00.088495", "end": "2024-07-02 07:06:47.591159", "msg": "non-zero return code", "rc": 1, "start": "2024-07-02 07:06:47.502664", "stderr": "ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable", "stderr_lines": ["ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable"], "stdout": "", "stdout_lines": []}
这次尝试后,我注释了 help.yml 并再次尝试,显然数据库创建成功了,但仍然存在权限问题。现在的错误是:
TASK [mysql : Create user with password, all database privileges - RedHat] *********************************
fatal: [192.168.1.202]: FAILED! => {"changed": false, "msg": "(1290, 'The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement')"}
fatal: [192.168.1.200]: FAILED! => {"changed": false, "msg": "(1290, 'The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement')"}
我刚刚用 mysql 用户尝试了这篇文章中所说的内容( --skip-grant-tables 选项无法执行语句 ),结果显示此消息:
mysql: unknown variable 'init-file=/var/lib/mysql/mysql-init'
我也刚刚尝试找到套接字,但在 RedHat 系列中我没有找到它可以使用,我不知道是否需要一些配置才能做到这一点。