Category Archives: MYSQL

[Solved] MYSQL:1153 Got a packet bigger than ‘max_allowed_packet’ bytes

1153: got a packet bigger than ‘Max_ allowed_ Packet ‘bytes

There are two solutions to this problem:

1. Temporary modification:

mysql>set global max_allowed_packet=524288000; #修改 512M

2. To modify my.cnf (my.ini under Windows), restart mysql
add a sentence in the [mysqld] section (if it exists, adjust its value):
Max_ allowed_ Packet = 256M (adjust the value according to the actual situation)

You can use the command:

show VARIABLES like '%max_allowed_packet%’;

Check whether the modification is successful!

[Solved] OpenStack Error: MariaDB ERROR 2002 (HY000): Can’t connect to MySQL server on ‘controller’ (115)

 

Solution:

vi /etc/my.cnf.d/openstack.cnf      # If you don't have this, fix my.cnf or Baidu 'Centos modify MariaDB configuration file'
Comment out the original assignment of bind-address
and change it to
bind-address=0.0.0.0

 

 

 

 

Resolution process backtracking

 

There are old problems when deploying t version keystone. The troubleshooting process is as follows

PS: dual node, hostname – > controller -> 10.0.0.11

1.Troubleshoot MySQL command access rights
    a. mysql -h localhost -u<db_name> -p<db_pass> -e 'show databases;'
    b. mysql -h controller -u<db_name> -p<db_pass> -e 'show databases;'
    c. mysql -h 192.168.75.128 -u<db_name> -p<db_pass> -e 'show databases;'
    d. mysql -h 10.0.0.11 -u<db_name> -p<db_pass> -e 'show databases;'

    Result: b, d not pass

2. troubleshoot Mysql table
    MariaDB [(none)]> select host,user from mysql.user;     # Grant localhost & %
    Add:
    MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'controller' IDENTIFIED BY 'keystone';
    MariaDB [(none)]> flush privileges;

    Result: No (This method solved some problems when deploying R version)

3. troubleshoot the Mysql configuration file
    vi /etc/my.cnf.d/openstack.cnf
    bind-address=192.168.75.128 change to bind-address=0.0.0.0

    Outcome: ok

[Solved] MYSQL Error: Cannot delete or update a parent row: a foreign key constraint fails

1 problem
when deleting data or tables associated with foreign keys, MySQL reports an error:

Cannot delete or update a parent row: a foreign key constraint fails

2 solution

SET foreign_key_checks = 0; // First set the foreign key constraint check off

drop table mytable; // Delete the data, table or view

SET foreign_key_checks = 1; // Turn on foreign key constraint checking to maintain the structural integrity of the table
First turn off foreign key constraints, perform the delete operation, and then turn on foreign key constraints

MYSQL Error: Out of sort memory, consider increasing server sort buffer size; nested exception is java.sql.SQLException: Out of sort memory, consider increasing server sort buffer size

MYSQL Error: Out of sort memory, consider increasing server sort buffer size; nested exception is java.sql.SQLException: Out of sort memory, consider increasing server sort buffer size
The Java interface suddenly reports an error with the error message Out of sort memory, consider increasing server sort buffer size.
The literal meaning is Out of sort memory, consider increasing server sort buffer_size.
mysql> show variables like ‘%sort_buffer_size%’;
+————————-+———+
| Variable_name | Value |
+————————-+———+
| innodb_sort_buffer_size | 1048576 |
| myisam_sort_buffer_size | 8388608 |
| sort_buffer_size | 262144 |
+————————-+———+
3 rows in set (0.01 sec)
You can see the sort_buffer_size, at this time you need to adjust the corresponding data larger
mysql> SET GLOBAL sort_buffer_size = 1024*1024;
Query OK, 0 rows affected (0.00 sec)

Retest

 

ORA-30567: name already used by an existing [How to Solve]

ogg error message:
2021-08-24 18:10:49 ERROR OGG-01489 Oracle GoldenGate Capture for Oracle, yz01.prm: Could not add TRAN DATA for table, error [ORA-30567: name already used by an existing
log group SQL ALTER TABLE “YZ”.”LAAGENTB” ADD SUPPLEMENTAL LOG GROUP “GGS_75783” (“EDORNO”,”AGENTCODE”) ALWAYS /* GOLDENGATE_DDL_REPLICATION */], error code [30567], operation [ALTER TABLE “YZ”.”LAAGENTB” ADD SUPPLEMENTAL LOG GROUP “GGS_75783” (“EDORNO”,”AGENTCODE”) ALWAYS /* GOLDENGATE_DDL_REPLICATION */ (size 131)].2021-08-24 18:10:50 ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, yz01.prm: PROCESS ABENDING.
Query log group GGS_75783 on that table by querying dba_log_groups, dba_log_group_columns view

Delete the log group
alter table yz.TMPLJAPAYPERSON drop SUPPLEMENTAL LOG GROUP “GGS_75783”
In the startup process
LAAGENTB, TMPLJAPAYPERSON 2 tables will automatically add table-level attachment logs
Add additional logs
alter table test add supplemental log data(all,primary key,unique,foreign key) columns;
Delete the additional log
alter table test drop supplemental log data(all,primary key,unique,foreign key) columns;
Note: This kind of delete supplemental log may report an error
Suggest to delete the supplemental log group
alter table yz.TMPLJAPAYPERSON  drop SUPPLEMENTAL LOG GROUP “GGS_75783”

Duplicate entry ‘1’ for key ‘PRIMARY'() [How to Solve]

When using MySQL + ibatis for insertion test, an error is reported: the information is as follows:

com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/study/ibatis/Student.xml.  
--- The error occurred while applying a parameter map.  
--- Check the addStudent-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'PRIMARY'
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
    at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:58)
    at com.study.ibatis.StudentDaoImpl.addStudent(StudentDaoImpl.java:33)
    at com.study.ibatis.TestIbatis.main(TestIbatis.java:14)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'PRIMARY'
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.Util.getInstance(Util.java:381)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:995)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:80)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
    ... 5 more
false

The meaning of the error is: repeatedly enter the “1” key as “main” to enter the database and query the table TBL_When I was a student, I found three records, one of which has a primary key of 1. Considering that when I test, the default primary key in the database is 1. Therefore, delete the record with primary key 1 in the database. Then the test passed

 

Summary: I set the primary key in ibatis to the default 1. As a result, the test starts directly from the default 1. Then the problem is solved by reporting an error and setting the default value of the primary key to null

Troubleshooting MySQL Python error on MAC

Error in installing MySQL pyhton on MAC

Today, I reported an error when installing MySQL Python on MAC , searched the network and said that there was a problem with the MySQL config path, but it didn’t work

Solution

The initial problems were:

Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-NknW3b/MySQL-python/setup.py", line 17, in <module>
    metadata, options = get_config()
  File "setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "setup_posix.py", line 25, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-NknW3b/MySQL-python/

 

After searching, I found that brew install mysql-connector-c , install brew install mysql-connector-c ,
reinstall MySQL Python , and found that an error was still reported, but the error information changed:

Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-u39xuY/MySQL-python/setup.py", line 17, in <module>
    metadata, options = get_config()
  File "setup_posix.py", line 53, in get_config
    libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
  File "setup_posix.py", line 8, in dequote
    if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-u39xuY/MySQL-python/

I searched the Internet, but the solutions were wrong. Finally, I found that there was a configuration problem with mysql-connector-c , so I modified the file

/usr/local/Cellar/mysql-connector-c/6.1.11/bin/mysql_config:

 

cd /usr/local/Cellar/mysql-connector-c/6.1.11/bin/
cp mysql_config mysql_config.bak
sudo vim mysql_config

# Create options
libs="-L$pkglibdir"
# libs="$libs -l "
libs="$libs -lmysqlclient -lssl -lcrypto "

Then reinstall pip install MySQL-python, Done!