Author Archives: Robins

Set the default time to the current value in MySQL

Mysql> create a table by adding this column and stating default values as follows:

CREATE TABLE `table1` (
  `id` int(11) NOT NULL,
  `createtime` timestamp NULL default CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

If you are operating under Navicat, set the field type to TIMESTAMP, and write CURRENT_TIMESTAMP as the default value, as shown below:

Add a new column to an existing table

ALTER TABLE table1
ADD COLUMN  `createtime` timestamp NULL DEFAULT CURRENT_TIMESTAMP

3. Modify the time format of a column and add the default value

alter table table1 
 change createtime newtime timestamp null default current_timestamp

MySQL uses net start MySQL startup prompt (failed to start, the service did not report any error)

Is there a data folder in the root directory of the MySQL installation?The data folder cannot be created manually because there is no data file for the manual creation. You need to use the following command
Mysqld — the initialize – insecure
Initialize the data files under dataDir, and then a data folder will appear under the root directory of the installation, which will contain a bunch of files
If an error occurs during this process, follow the following steps to re-execute it
First uninstall the service using the mysqld — remove command
Then install it using the mysqld — install command
I then initialize it using mysqld –initialize-insecure

Windows command to start MySQL “system error 5”

System error 5 occurred and access was denied when MySQL was restarted in CMD, as shown below:

This error is caused by insufficient permissions to operate CMD. The solution is as follows:
Enter CMD in the search bar of the start menu, right-click the search results, and select run as administrator!

If the frequency of CMD use is high, the following is a once-and-for-all method:
1. Right click on Cmd and select “Attend to Start Menu (U)” to find Cmd in Start Menu.
2. Right-click to select properties, select shortcut, then select advanced, select to run as administrator, and then click OK!
Just open the Start menu and click the shortcut above to run CMD as an administrator!
Net start mysql = net start mysql = net start mysql
 
 
In addition, some prompt that the server name is invalid

 
Different MySQL may have different names
Therefore, it needs to be modified to
Net start MySQL56
 
 
 

Differences between Java and kotlin access modifiers

modifiers

Java

Kotlin

public

all kind of visible

all kind of visible (the default)

private

current class visible

current class visible

prote Cted

the current class, subclass, class is visible under the same package path

the current class, subclass visible

default

class visible (the default) under the same package path

no

internal

no

class is visible in the same module

Su – MySQL switch user, display error: resource temporarily unavailable

The problem
Mysql> su -mysql -mysql>

su: failed to execute /bin/bash: Resource temporarily unavailable

To solve
/etc/securitymits. D ,
, <>> mysq. conf> code>, mysq.>f>

mysql soft nofile 131072
mysql hard nofile 131072
mysql soft nproc 65535
mysql hard nproc 65535

Limits. D overwrites the Limits.
oblem solved.
Information about the description file limits. Conf can look at this article:
https://blog.csdn.net/fanren224/article/details/79971359

Waitpid call return error prompt: no child processes problem

The problem
An error occurred in a function today with a probabilistic waitpid call. The error is No child processes. The prompt does not have this child process, the PID number can also be wrong, so add the print, when the duplicate found that the PID number can correspond to, no problem.
online, found “No child” the processes of error code corresponding ECHILD, waitpid there is in man’s document, if the process set the SIGCHLD signal processing to SIG_IGN, then the call will return ECHILD waitpid.
to see the code, the parent process does have to capture the SIGCHLD signal inside, for processing way

rc = waitpid(-1, &status, WNOHANG);

Wait for any child process to exit so that it can be recovered. I suspect that calling WaitPid again when the parent process has already collected its body will be an error. And that explains the probabilistic problem. So write the following code to verify it.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>

void sig_handle(int sig)
{
    waitpid(-1, NULL, 0);
    printf("llm->%s(%d)\n", __FUNCTION__, __LINE__);
}

int main(int argc, char *argv[])
{
    int rtn = 0;
    int pid = 0;
    char *arg[] = {"date", NULL};
    signal(SIGCHLD, sig_handle);
    //signal(SIGCHLD, SIG_IGN);

    while(1)
    {
        pid = fork();
        if(!pid)
        {
            execvp("date", arg);
            exit(1);
        }
        usleep(10*1000);
        rtn = waitpid(pid, NULL, 0);

        if(rtn < 0)
            perror("waitpid");
        //usleep(10*1000);
    }
    return 0;
}

If you add sleep before waitpid, the problem will be 100% duplicated. If you remove sleep, there will be no problem.
The solution
Given the current code logic, there is a problem with either Waitpid being removed, so the best course of action is to determine whether it is true or false. If Waitpid returns ECHILD, then ignore the error.
The system calls
This is not a problem with the system call. This is not a problem with the implementation of waitpid after fork. The implementation handles the signal accordingly. The SIGCHLD signal processing action is restored before fork, as follows:

int __libc_system(char *command)
{
	int wait_val, pid;
	__sighandler_t save_quit, save_int, save_chld;

	if (command == 0)
		return 1;

	save_quit = signal(SIGQUIT, SIG_IGN);
	save_int = signal(SIGINT, SIG_IGN);
	save_chld = signal(SIGCHLD, SIG_DFL);

	if ((pid = vfork()) < 0) {
		signal(SIGQUIT, save_quit);
		signal(SIGINT, save_int);
		signal(SIGCHLD, save_chld);
		return -1;
	}
	if (pid == 0) {
		signal(SIGQUIT, SIG_DFL);
		signal(SIGINT, SIG_DFL);
		signal(SIGCHLD, SIG_DFL);

		execl("/bin/sh", "sh", "-c", command, (char *) 0);
		_exit(127);
	}
	/* Signals are not absolutly guarenteed with vfork */
	signal(SIGQUIT, SIG_IGN);
	signal(SIGINT, SIG_IGN);

#if 0
	printf("Waiting for child %d\n", pid);
#endif

	if (wait4(pid, &wait_val, 0, 0) == -1)
		wait_val = -1;

	signal(SIGQUIT, save_quit);
	signal(SIGINT, save_int);
	signal(SIGCHLD, save_chld);
	return wait_val;
}
weak_alias(__libc_system, system)

Git bash display error can not be used, how to solve

Solution:
It seems that the 64-bit version will have problems, but 32-bit Git can also be installed on 64-bit systems.
Once you have unloaded your 64-bit Git installation, download a 32-bit Git installation and you will be able to use it normally.
Of course, your 32-bit error, unloaded after the same process, install 64-bit, this will not be a problem, but 32-bit more stable.

Reproduced in: https://www.cnblogs.com/flxy-1028/p/6922987.html