Tag Archives: database

Ubuntu: Redis starts the project Error [How to Solve]

redis.exceptions.ResponseError: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

Cause: redis snapshot forced to close, resulting in the problem of not being able to persist
Solution.
1. Avoid this problem by setting the stop-writes-on-bgsave-error value to no.

Through the redis command line directly to change.
Go to the redis command line and execute: config set stop-writes-on-bgsave-error no

2. Change the stop-writes-on-bgsave-error value to no by modifying the redis.conf configuration file (same effect as 1)

By modifying the redis.conf file modify.


Finally, remember to restart redis: /etc/init.d/redis-server restart (If restarting doesn’t work, try stopping redis first [/etc/init.d/redis-server stop] and then starting it again [/etc/init.d/redis-server start].

How to Solve Namedparameterjdbctemplate.queryforobject() Return Error

Project scenario:

tip: briefly describe the project background here:
for example, project scenario: example: communicate with mobile app through Bluetooth chip (hc-05), and transmit a batch of sensor data every 5S (not very large)


Problem Description:

The following code will report an error if it can’t be found in the database, and it doesn’t work whether you judge it to be empty or judge the length.

@Override
public String queryUserNameByUserId(String userId) {
	String sql = "SELECT username FROM info WHERE userId= :userId";
	MapSqlParameterSource source = new MapSqlParameterSource();
	source.addValue("userId", userId);
	return namedParameterJdbcTemplate.queryForObject(sql, source, String.class);
}

Cause analysis:

Queryforobject(), try to operate when querying data that must exist in the database.

Solution:

1. Try catch is not recommended
2. Change to list and judge to be empty, as follows.

@Override
public List<String> queryUserNameByUserId(String userId) {	//Modify
	String sql = "SELECT username FROM info WHERE userId= :userId";
	MapSqlParameterSource source = new MapSqlParameterSource();
	source.addValue("userId", userId);
    return namedParameterJdbcTemplate.queryForList(sql, source, String.class);	//修改
}

Error: the version of ZABBIX database does not match the current requirements

Error: the ZABBIX database version does not match current requirements. Your database version: 5000000. Required version: 4000000. Please contact your system administrator

Cause of problem:
the current database version is inconsistent with the required database version
solution:
log in to the database and modify the mandatory value of the database version to 4000000

MariaDB [(none)]> use zabbix;
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
MariaDB [zabbix]> select version();
+----------------+
| version()      |
+----------------+
| 5.5.68-MariaDB |
+----------------+
1 row in set (0.00 sec)

MariaDB [zabbix]> update dbversion set mandatory=4000000;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [zabbix]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [zabbix]> select version();

Restart ZABBIX server

Sqlyog connection error: error number 2058

Sqlyog connection error: error number 2058

MySQL version: 8.0.21sqlyog configuration new connection error, error number 2058

resolvent

Open CMD as an administrator and log in to your MySQL database: MySQL - U root - P execute this statement according to your situation: alter user 'root' @'localhost 'identified with MySQL_ native_ Password by 'password to modify' after running successfully, reconfigure the connection to sqlyog to succeed

Error querying database.Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.

Record the problems encountered in the learning process of Java mybatis framework

1. An exception occurred while building the first mybatis project:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 

Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. 
Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver

Solution: the MySQL connector Java driver version is used incorrectly
I use MySQL version 8.0.22

import the driver of version 5.1.23, and the dependency declared in pom.xml file is

<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.23</version>
    </dependency>

The two versions do not correspond, so the driver error cannot be found.
the solution is to download the driver of version relative to, that is, the driver of version 8.0.22. The official website address is version 8.0.22
and then change the dependency in the POM file to:

<!--MySQL-->
<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.22</version>
    </dependency>

Another point is that the POM file should include not only driver dependencies, but also mybatis dependencies

<!--mybatis-->
<dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.5</version>
    </dependency>

Mysql8.02/ubuntu 20 ERROR 1449 (HY000) [How to Solve]

Just after installing MySQL through apt install MySQL server, I encountered a pit. After checking for a long time, I finally found the answer. Thank you, netizens.

mysql> show databases;
ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist

If you enter mysql, you will report an error. I don’t know why. Confused B

mysql> create user ' mysql.infoschema '@'% 'identified by' password ';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to 'mysql.infoschema'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying XXX

PG database SQL error:
error reason: is caused by SQL writing error or parameter transfer error
database error information

[42883] ERROR: operator does not exist: character varying = record 
No operator matches the given name and argument types. You might need to add explicit type casts. 
line: 1063

error example:

select * from d_allotmoveai_setarea a where a.bills_id = ('123','456')

correct example:

select * from d_allotmoveai_setarea a where a.bills_id = ('456')
select * from d_allotmoveai_setarea a where a.bills_id in ('123','456')

ERROR Message:
org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying <> record No operator matches the given name and argument types. You might need to add explicit type casts. line: 323 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578) ~[postgresql-42.2.11.jar:42.2.11] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313) ~[postgresql-42.2.11.jar:42.2.11] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331) ~[postgresql-42.2.11.jar:42.2.11] at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448) ~[postgresql-42.2.11.jar:42.2.11] at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) ~[postgresql-42.2.11.jar:42.2.11] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:159) ~[postgresql-42.2.11.jar:42.2.11] at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:109) ~[postgresql-42.2.11.jar:42.2.11] at com.p6spy.engine.wrapper.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:78) ~[p6spy-3.9.1.jar:na] at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-3.4.2.jar:na]

Solve MySQL installation error: initializing database prompts an error when installing mysql

Solve MySQL installation error: initializing database prompts an error when installing mysql

when we install MySQL database, we report an error in initializing database because MySQL has not been completely uninstalled before. We can solve it according to the following methods:

1. First stop the original MySQL service

-Right click my computer
– select “management”
– click “service”
– find MySQL
– right click to close the service

2. Enter the control panel to uninstall mysql

in the panel, right-click Mysql to uninstall, and then follow the steps prompted to uninstall

3. Go to MySQL installation directory and delete relevant files

generally, the database is on Disk C by default. Open it in the file browser, and then check the “hidden items” to open the following three files

– Program Files
– Program Files (x64)
– ProgramData

delete the MySQL directory under these three folders

4. Clean the registry and completely delete the MySQL service

Press and hold the windows key + r on the keyboard to open the command line, enter regedit to enter the registry
and find it in turn:

HKEY_ LOCAL_ MACHINE——SYSTEM——ControlSet001——services——eventlog——Application——MySQL

right click the MYSQL to delete it. If there are still the following directories:

HKEY_ LOCAL_ MACHINE——SYSTEM——ControlSet002——services——eventlog——Application——MySQL

you can also right-click to delete. If not, it will be ignored

5. Restart the system

Error querying database. Cause: java.util.ConcurrentModificationException

Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.util.ConcurrentModificationException
### Cause: java.util.ConcurrentModificationException
at org.apache.ibatis.exceptions.ExceptionFac

For the iterative stability problem, it is used for database query. The value of lastbyparam.getid is re assigned to ID, and an error is reported due to the reference of the object; Another problem is that valueconfig is the value obtained from Nacos. The global variable cannot always add ID, and the collection will slowly grow

List<Long> Ids = valueConfig.getIds();
Ids.add(Id);
ObjectDO lastByParam = testMapper.getLastByParam(userId, Ids, null);
if (lastByParam != null){
    Id = lastByParam.getId();
}

The solution is to re new a collection

Redis: (error) MOVED 8352 192.168.145.128:6380 [How to Solve]

Problem Description:

Redis set, get and other operations have the following errors

 (error) MOVED 8352 192.168.145.128:6380

Cause analysis:

This is generally caused by the fact that the cluster mode is not set when redis cli is started; After starting the cluster, redis cli logs in as an ordinary user and cannot operate the data in the cluster. You need to add – C to log in as a cluster mode before you can operate.

Solution:

Add – C at startup to start cluster mode

redis-cli -c -p 6379

As shown in the figure below, the operation can be successfully performed

Summary

Login in normal mode: you may directly enter the read host and move redirection will occur when storing data. Therefore, you should log in as a cluster. Add the – C parameter to connect with the cluster policy, and the setting data will be automatically switched to the corresponding write host

phpstudy Error while setting value ‘STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

Today, I came to phpstudy. I found that MySQL could not be opened and reported this error. After a round of search, I solved the problem
Modify mysql.ini

sql_ mode =‘STRICT_ TRANS_ TABLES,NO_ ZERO_ IN_ DATE,NO_ ZERO_ DATE,ERROR_ F
OR_ DIVISION_ BY_ ZERO,NO_ AUTO_ CREATE_ USER,NO_ ENGINE_ ‘
I solved it like this. It depends on whether you can do it or not

Others have provided the following solutions
1. Phpstudy upgrade, SQL_ Mode is followed by more spaces. Just delete the spaces

2、 Directly annotate SQL_ Mode line content( After I do this, MySQL starts and then stops, and goes back and forth ε=( ´ ο`*))) Alas)

3、 Remove SQL_ No in mode_ AUTO_ CREATE_ USER

4、 SQL_ mode = NO_ AUTO_ CREATE_ USER,NO_ ENGING_ SUBSTITUTION

All the above are modified in mysql.ini

MySQL (version 8.0) connection error: 1251 [How to Solve]

1. Error reporting

2. Reasons for error reporting

Because the encryption method of MySQL 8.0 is different from that of MySQL 5.0, an error will be reported when connecting

3. Solutions

You need to change the encryption method to connect successfully (follow the steps below).

1. Enter the DOS command and execute the following code to enter the database

mysql -uroot -proot //-u(database account) -p(database password)

2. Execute the following command

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password set during mysql installation';

You can also change the password with this command: change the password in the command to the new one

After completing the above two steps, there will be no error when connecting again.