Tag Archives: mysql

The time of the time database displayed by the front end is inconsistent

These days I have encountered a huge pit. The time of data storage is 2 o ‘clock, but the time displayed on the front page is 16 o ‘clock, which is 14 hours short.
Describe the project background, the service is in the US, the project is a Mexican project, the database time and server time have been set to the Mexican time zone, but it is still not correct.
I have asked the project boss in the middle, and the boss gave me the opinion that the time zone was set on the URL of connecting data, but the front-end page was still not displayed correctly.
After several times of locating, the time to find it directly in the dev location will change. This is because the computer’s time zone is the Chinese time zone. But the time log is still on the server, the log time is correct. So guess the front-end is the time zone problem.
Because the last segment passes the timestamp, the timestamp has no time zone. So the front end also needs to change the time zone to correspond

  id : "crete_time",
		            renderer : function(idValue,value,record){
                        return value ?moment(value).tz("America/Guatemala").format("YYYY-MM-DD HH:mm:ss") : "---";
			        }

You can set the time zone using the Moment.tz method

Tar: due to the previous error, it will exit with the last error state

Official website to download the mysql connector – odbc – 8.0.21 – Linux – glibc2.12 – x86-64 – bit. Tar. Gz encountered error: tar ZXVF decompression –
Tar: Exits the previous error state because of the previous error
Solution: the source package placed in /home directory can be decompressed successfully
The reason has not been analyzed yet. If you want to see it, you can comment and reply to discuss and communicate with us

Install / Remove of the Service denied! Error occurred when installing MySQL service

Mysqld –install /Remove of the Service Denied: install /Remove of the Service Denied: mysqld –install /Remove of the Service Denied: install /Remove of the Service Denied: Wrong. Strange.
 
This time, you need to right-click “Run as Administrator”, and then type mysqld –install
 
OK, the service is installed successfully!

Call to undefined function mysql_ Connect() solution summary

A:
Use the phpinfo() function in your PHP code to see PHP basics
Mysql_connect () has been deprecated since PHP5.0, and is deprecated in PHP7.0. Mysqli_connect () is used instead if PHP is 7.0 or higher
Method 2:
Missing MySQL module caused by PHP installation
Mysql> install mysql from CentOs
yum install php-mysql -y
If installed, report the following warning
Headers and client library minor version mismatch. Headers:
This is due to the higher version of MySQL, the lower version of the MySQL Client API
You can uninstall php-mysql first
yum remove php-mysql -y
then
yum install php-mysqlnd -y
Finally, restart Apache
systemctl restart httpd
Ubuntu install MySQL module:
Apt to get the install php5 – mysql
Sudo DPKG — reconfigure php5 – mysql
sudo /etc/init.d/mysql restart
sudo /etc/init.d/apache2 restart
Three:
If the first two methods fail, try opening the MySQL module extension in the php.ini configuration file
Php.ini = php.ini; Extension =” related MySQL module “; To get rid of
Then make sure that the dir of extension points to the directory where the extension resides
Windows is usually under Ext and CentOS is under /usr/lib64/php.modules
The above information can be found in the PHPINFO printed information
However, when I encountered this problem, I just needed to install the PHP-MySQL module, and I didn’t need to modify php.ini
My environment is Centos7 and PHP version is PHP5.4
 

Fatal error: Uncaught Error: Call to undefined function mysql_ Connect() problem solving

Fatal error: Uncaught error: Call to undefined function mysql_connect() : Fatal error: Uncaught error: Call to undefined function mysql_connect() when connecting to the database using PHP validation code. This is because the version of PHP you are using does not support the older version of join statement writing. The PHP version used in this study is PHP-7.4.2-NTS-Win32-VC15-x64, and the verification code is:
< ?PHP
the mysql_connect (‘ 127.0.0.1 ‘, ‘runner_db_user’, ‘runner_db_password’)
the OR die (” Could not connect to the database. ‘);
the mysql_select_db (‘ hfjq_race_info ‘);
echo “Connected!” ;
?>
After inquiry, this writing method is the previous version of 5. X, the following code is as follows:
< ?php
$con=mysqli_connect(“127.0.0.1”, “runner_db_user”, “hfjq_race_info”)
OR die(‘Could not connect to database.’);
echo “Connected!” ;
?>
You can connect to the database normally. If you have extension=mysqli, change the semicolon “;” before extension=mysqli. You can connect to the MySQL database normally if you remove it

Uncaught error: call to undefined function MySQL when building sqli lab environment with phpstudy_ Connect() error

The problem

Uncaught Error: Call to undefined function mysql_connect()

why
In PHP 5+, you can use both mysql_connect() and mysqli_conncet() instead of mysqli_conncet().
The solution
In the PHPStudy environment, you can downgrade the PHP version by selecting the PHP5 + version.
>
>

Web site – & gt; Management – & gt; PHP version. (You can choose to replace an older version of PHPStudy.)
If you want to use php7 without changing the code, you can use the admin ->; For PHP extensions, check the box before php_mysql.

MySQL advanced — Explanation of ref field in explain information

1. Explain the ref field in the Explain information
Indicates which column of the index is used, if possible, as a constant. Which columns or constants are used to find values on indexed columns
2. Explain the ref field in the information

From key_len we can see that IDX_COL1_COL2 of table T1 is fully used, that col1 matches col1 of table T2, and that col2 matches a constant, that is, the fields associated with other tables in the ‘AC’ query, and that the foreign key relationship is indexed

Import / export. SQL file / gzip file for MySQL under Linux

    ready. SQL file and upload to server login server MySQL import. SQL file
If you need to create the database for the entire database file you don’t need to create the database for the table file
Source *.sql //.sql file path
 
3. Export. SQL file
Export table structure
It’s going to be in the data directory
cd /mysql/data/
. /bin/mysqldump -uroot -p -d newdb > Newdb.sql // newdb database name
// Enter the password
 
Export data and table structures
It’s going to be in the data directory
cd /mysql/bin/
. /bin/mysqldump -uroot -p newdb > Newdb.sql // newdb database name
// Enter the password
 

    exports the gzip file
It’s going to be in the data directory
. /bin/mysqldump -uroot -p –default-character-set=utf8 xw_taes | gzip > /home/xw_taes_1.sql.gz
// Enter the password
 

    import gzip
In any directory
gzip -d < /home/xw_taes_1.sql.gz | mysql -uroot -p xw_taes_1
// Enter the password
Xw_taes_1 is the name of the database to import
There is no meeting

 
Note: Adding plaintext password directly will report an error

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