Category Archives: MySQL

Error running ‘Application‘: Command line is too long [How to Solve]

2021.11.18

When idea starts a new project, a pop-up prompt error is encountered

Error running ‘xxx Application’:Command line is too lang. Shorten command line for Application or aalso for Spring Boot default configuration

Error reason: the springboot project startup command is too long

Solution:

The first method (protest is effective)

Step 1: find the idea/workspace.xml file in the project, and then find <component name="PropertiesComponent"> </component > tag, as shown below

step2:Add a line to the component tag < property name="dynamic.classpath" value="true"/>, as shown below

Restart the project.

[Solved] workbench ssl connection error ssl is required but the server

Background

Workbench connection error SSL connection error SSL is required but the server, as shown in the figure below

Solution:

stay https://stackoverflow.com/questions/69824631/mysql-workbench-ssl-connection-error-ssl-is-required-but-the-server-doesnt-sup/69828778 To find a solution, select if availablefor use SSL. However, it is found that the latest version of MySQL workbench 8.0.27 does not have this option. So I downloaded the old version MySQL workbench 8.0.16 , modified the SSL option, and the test results are shown in the figure below
in consideration of downloading workbench to log in, I have prepared the download address for your convenience.

https://sourceforge.net/projects/generic-software/files/workbench/

[Solved] ERROR com.alibaba.druid.pool.DruidDataSource – init datasource error, url jdbcmysql

Error reporting when deploying an open source project

ERROR com.alibaba.druid.pool.DruidDataSource - init datasource error, url jdbcmysql://

Obviously, there is a database connection error

But after eliminating the error, I can find the real cause of the error

Database connection address error

Network problems

Wrong user name and password

Finally, it was found that there was a problem with the MySQL driver version of the open source project, which was inconsistent with the MySQL I installed

Solution:

Go to POM.XML and delete the version information of MySQL, which can be used by default, as shown below

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

[Solved] Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.Mon Nov 15 20:44:52 CST 2021
There was an unexpected error (type=lnternal Server Error, status=500).
Could not open JPA Entity/Manager for transacton, nested exception is org.hibernate.exceptionGenericDBCException:
Unable to acquireJDBCConnection

During the debugging of idea, I encountered a problem on the browser side. I found it for many days and finally solved it. That is, the JDBC version of the connection between idea and MySQL does not match. Let’s share the method below
if you see an error, it is probably a JDBC connection problem. First, check the configured MySQL user name, password and URL

After making sure that everything is correct, check whether my MySQL version corresponds to the idea version. Before I made an error, the MySQL jar package in the idea is 5.0, but my idea version is higher than mysql, so I can’t connect. Then I go to the MySQL 8.0 jar package under the official website, import it into the idea, and then change the JDBC version in pom.xml


  • In the higher version of JDBC, spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver is generally added with a cj.

This is the previous
this is the current

later, there will be no JDBC connection problem when running on the server side! This is my problem solved, others may have more situations. Here only represents my own solution!

[Solved] mysqldump Command Error: Got error: 2002: “Can‘t connect to server on ‘127.0.0.1‘ (36)“ when trying to connect

1. When executing mysqldump command for data backup, the error information is as follows:

~ % mysqldump -udbuser -p123456 -h127.0.0.1 school student  > school_student.sql 
mysqldump: Got error: 2002: "Can't connect to server on '127.0.0.1' (36)" when trying to connect

2. Then try the command line to connect to the database, which is also an error

~ % mysql -udbuser -p123456 -h127.0.0.1
ERROR 2002 (HY000): Can't connect to server on '127.0.0.1' (36)

3. After checking the MySQL service result, I remembered that I used ‘mysql. Server start’ to start the database. This cannot follow the system startup. Each time I restart the Mac, I need to run it manually. You can use brew services to start MariaDB   Start the service with the system.

~ % mysql.server start
Starting MariaDB
.211111 16:04:44 mysqld_safe Logging to '/usr/local/var/mysql/xiaokang.err'.
211111 16:04:44 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
 SUCCESS! 

4. After successful restart, execute mysqldump again for backup

MYSQL Error: Can‘t find error-message file [How to Solve]

Installing MySQL
is running

mysqld --initialize --console

An error was encountered while

2021-11-06T18:04:30.907573Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'C: ofterwaresetting\mySQL\mysql-8.0.11-winx64 hare\english\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

After checking many tutorials, I finally found that there was a problem with the escape character:
https://bugs.mysql.com/bug.php?id=90364

In short, change the path to double slash \ in my.ini file,
for example:

basedir=C:\\softerwaresetting\\mySQL\\mysql-8.0.11-winx64
datadir=C:\\softerwaresetting\\mySQL\\mysql-8.0.11-winx64\\Data
lc-messages-dir=C:\\softerwaresetting\\mySQL\\mysql-8.0.11-winx64\\share\\english

[Solved] SQL Error: Method queryTotal execution error of sql

In a connection query, there is no problem with the query in the MySQL query tool. It is pasted into the mapper.xml file in the project, but the runtime reports mybatisplusexception: error: method querytotal execution error of SQL:

 SELECT
        ANY_VALUE(e.id)  AS "id",
        ANY_VALUE(e.project_no) AS "projectNo",
        ANY_VALUE(sampleIn.sample_id)  AS "fieldNumber",
        ANY_VALUE(e.subject_no) AS "laboratoryNumber",
        ANY_VALUE(e.type) AS "type",
        ANY_VALUE(d.sampling_location) AS "location",
        ANY_VALUE(sampleIn.in_quantity)   AS "inquatity",
        ANY_VALUE(sampleIn.create_date)  AS "createDate",
        ANY_VALUE(sys_user.name)  AS "createUser",          
        ANY_VALUE(s. project_no)  AS "projectNoName",
        ANY_VALUE(s.subject_name)   AS "subjectName",
        ANY_VALUE(sd.name) AS "saveCondition",
        ANY_VALUE(sa.location) AS "location",
        ANY_VALUE(DATE_FORMAT(sa.shelf_life,'%Y-%m-%d'))AS"shelfLife"
        FROM labcode e
        LEFT JOIN labprojects s ON e.project_no = s.id
        LEFT JOIN labprojectplan n ON s.id = n.project_no        
        LEFT JOIN labprojectplan_field d ON n.id = d. lab_project_plan_id  AND e.serial_number = d.serial_number AND e.letter_code =d.letter_code    
        LEFT JOIN labsubjectsample sa ON e.id =sa.laboratory_number
        LEFT JOIN laboratorysamplein sampleIn ON sampleIn.code_id = e.id
        LEFT JOIN sys_user ON sampleIn.create_user=sys_user.user_id
        LEFT JOIN sys_dict sd ON sd.code = sa.save_condition
        WHERE 1 = 1
        AND s.is_delete = 0
        AND e.is_delete=0
        AND e.subject_no LIKE '%B'
        AND e.type=3
       
        GROUP BY e.id     
        ORDER BY ANY_VALUE(sampleIn.create_date) DESC

After going online to search, it was confirmed that it was the problem of where conditions, so they were eliminated one by one, and finally locked on several is_delete fields, which are of char type in the database. The database query tool supports direct use of 0 and 1 to query, and MyBatis needs to contact the database Keep consistent in the middle, and finally, change the where part to

WHERE 1 = 1
        AND s.is_delete = '0'
        AND e.is_delete='0'
        AND e.subject_no LIKE '%B'
        AND e.type='3'

Problem-solving

This exception is basically the problem of where conditions, and type mismatch is only one of them. Other problems include condition null value, keyword conflict with framework and so on. As long as you are careful when writing code, think more about avoiding exceptions, be patient when problems occur, check them one by one, and be good at summarizing after problems are solved, you can accumulate experience and grow gradually on the way of writing code.

[Solved] ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate

The MySQL table structure is as follows:

mysql> select * from fruits ;
+------+------+------------+---------+
| f_id | s_id | f_name     | f_price |
+------+------+------------+---------+
| a1   |  101 | apple      |    5.20 |
| a2   |  103 | apricot    |    2.20 |
| b1   |  101 | blackberry |   10.20 |
| b2   |  104 | berry      |    7.60 |
| b5   |  107 | xxxx       |    3.60 |
| bs1  |  102 | orange     |   11.20 |
| bs2  |  105 | melon      |    8.20 |
| c0   |  101 | cherry     |    3.20 |
| l2   |  104 | lemon      |    6.40 |
| m1   |  106 | mango      |   15.70 |
| m2   |  105 | xbabay     |    2.60 |
| m3   |  105 | xxtt       |   11.60 |
| o2   |  103 | coconut    |    9.20 |
| t1   |  102 | banana     |   10.30 |
| t2   |  102 | grape      |    5.30 |
| t4   |  107 | xbababa    |    3.60 |
+------+------+------------+---------+

According to s_ ID groups the table data, and the error message is as follows

mysql> select * from fruits group by s_id;
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
 'exercise.fruits.f_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible 
 with sql_mode=only_full_group_by

Query SQL_Mode mode

mysql> select @@session.sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@session.sql_mode                                                                                                                        |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+

Reason: only is added after MySQL 5.7_full_group_By roughly means that the column you select must be included in group by (for example, select a, B from table, group by a, B;), or you are an aggregate column, such as sum(), avg(), max(). The
official website says that SQL mode affects the syntax supported by MySQL and the data verification checks it performs, This makes it easier to use MySQL in different environments and other database servers

Official website reference link: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-setting

Solution:

1. It is found that the set global setting in MySQL does not take effect and cannot be set under my.cnf

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

2. Query again is normal

mysql> select * from fruits group by s_id,f_name;
+------+------+------------+---------+
| f_id | s_id | f_name     | f_price |
+------+------+------------+---------+
| a1   |  101 | apple      |    5.20 |
| b1   |  101 | blackberry |   10.20 |
| c0   |  101 | cherry     |    3.20 |
| t1   |  102 | banana     |   10.30 |
| t2   |  102 | grape      |    5.30 |
| bs1  |  102 | orange     |   11.20 |
| a2   |  103 | apricot    |    2.20 |
| o2   |  103 | coconut    |    9.20 |
| b2   |  104 | berry      |    7.60 |
| l2   |  104 | lemon      |    6.40 |
| bs2  |  105 | melon      |    8.20 |
| m2   |  105 | xbabay     |    2.60 |
| m3   |  105 | xxtt       |   11.60 |
| m1   |  106 | mango      |   15.70 |
| t4   |  107 | xbababa    |    3.60 |
| b5   |  107 | xxxx       |    3.60 |
+------+------+------------+---------+

sql_Mode interpretation:

ONLY_FULL_GROUP_BY: For the GROUP BY aggregation operation, if the column in the SELECT is not in the GROUP
Appears in BY, then this SQL is illegal, because the column is not in the GROUP BY clause
 
NO_AUTO_VALUE_ON_ZERO: This value affects the insertion of self-growing columns. By default, inserting 0 or NULL means that the next self-increasing value is generated. If the user
Hope that the inserted value is 0, and the column is self-increasing, then this option is useful.
 
STRICT_TRANS_TABLES: In this mode, if a value cannot be inserted into a transaction table, the current operation is interrupted, and there is no restriction on non-transactional tables
NO_ZERO_IN_DATE: In strict mode, the date and month are not allowed to be zero
 
NO_ZERO_DATE: Set this value. The mysql database does not allow the insertion of a zero date. Inserting a zero date will throw an error instead of a warning.
 
ERROR_FOR_DIVISION_BY_ZERO: During INSERT or UPDATE, if the data is divided by zero, an error is generated instead of a warning. like
If the mode is not given, then MySQL returns NULL when the data is divided by zero
 
NO_AUTO_CREATE_USER: prohibit GRANT from creating users with empty passwords
 
NO_ENGINE_SUBSTITUTION:
If the required storage engine is disabled or not compiled, then an error is thrown. When this value is not set, replace with the default storage engine and throw an exception
 
PIPES_AS_CONCAT:
Treat "||" as a string concatenation operator instead of an OR operator, which is the same as the Oracle database and similar to the string concatenation function Concat
 
ANSI_QUOTES: When ANSI_QUOTES is enabled, double quotes cannot be used to quote a string because it is interpreted as an identifier

[Solved] MYSQL Master-Slave slave I/o for channel, error_code 1045

1. Background

A few days ago, a friend restarted the master database. The master-slave link was broken and “error_code 1045” was reported.

2. Solve

From the point of view of the error, it is because of a problem with the link authentication. You can compare whether the password is consistent with the password of the master_info file of the slave library. Most of them are caused by inconsistent passwords for some reason.

Solution:

stop slave;
change master to master_password='new_password';
start slave;

Hive install initialization error: Error: Duplicate key name ‘PCS_STATS_IDX‘ (state=42000,code=1061)

Error log

[root@mihaoyu151 conf]# schematool -dbType mysql -initSchema
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/bin:/opt/soft/jdk180/bin:/opt/soft/zookeeper345/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:/opt/soft/jdk180/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:/opt/soft/zookeeper345/bin:/opt/soft/hive110/bin)
21/11/09 14:25:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
21/11/09 14:25:20 WARN conf.HiveConf: HiveConf of name hive.server2.thrift.client.user does not exist
21/11/09 14:25:20 WARN conf.HiveConf: HiveConf of name hive.server2.thrift.client.password does not exist
Metastore connection URL:	 jdbc:mysql://192.168.133.151:3306/hive151?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 1.1.0-cdh5.14.2
Initialization script hive-schema-1.1.0.mysql.sql
Error: Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
*** schemaTool failed ***

Error reporting reason

Hive database already exists in MySQL

Solution:

Delete hive database in MySQL

[root@mihaoyu151 soft]# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 135
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive151            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> drop database hive151;
Query OK, 54 rows affected (0.13 sec)

mysql> exit;
Bye

[root@mihaoyu151 soft]# schematool -dbType mysql -initSchema
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/bin:/opt/soft/jdk180/bin:/opt/soft/zookeeper345/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:/opt/soft/jdk180/bin:/opt/soft/hadoop260/sbin:/opt/soft/hadoop260/bin:/opt/soft/zookeeper345/bin:/opt/soft/hive110/bin)
21/11/09 14:30:24 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
21/11/09 14:30:24 WARN conf.HiveConf: HiveConf of name hive.server2.thrift.client.user does not exist
21/11/09 14:30:24 WARN conf.HiveConf: HiveConf of name hive.server2.thrift.client.password does not exist
Metastore connection URL:	 jdbc:mysql://192.168.133.151:3306/hive151?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 1.1.0-cdh5.14.2
Initialization script hive-schema-1.1.0.mysql.sql
Initialization script completed
schemaTool completed

How to Solve MYSQL into outfile Error13

Error 13 is always reported when writing files. There is no problem viewing directory permissions. Finally, find the following solutions

Write files under Linxu
If you want to use the read and write functions, you must meet the following requirements

The current user is the root user
secure_file_priv is empty, or the folder to be written is just a specific folder of secure_file_priv
The folder where the shell is written must have 777 permissions, otherwise the writing will fail
File size, must be less than max_allowd_packet to
meet the above requirements in order to be written normally

Edit the file/etc/my.cof

Add
under [mysqld]

secure_file_priv =/var/www/html

MySQL view

and then

chmod 777 /var/www/html

Finally, restart the database