Tag Archives: mysql

Failed to obtain JDBC Connection

Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
My mysql is 5.7.25 maybe there is a problem with the installation mysql time zone is not set just set the time zone

 

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=CST

The ‘MySQL daemon failed to start’ solution appears

==================================================================

Ten million methods, backup the first!

==================================================================
running: Service mysqld start the following prompt will always appear when restarting the database:
MySQL daemon failed to start.
starting mysqld: [failed]
prompt. If you directly enter MySQL – root – P to log in, you will get an error [MySQL] error 2002 (HY000): can’t connect to local MySQL server through socket ‘/ var/lib/MySQL/MySQL. Socket’ (2). In short, MySQL server always fails to start. There are many solutions available on the Internet, which have no effect. In the end, the solution is as follows

RM – RF/var/lib/MySQL/* involves deleting and renaming the backup as follows MV/var/lib/MySQL// var/lib/MySQL_ Bak/ RM/var/lock/subsys/mysqld involves deleting and renaming the backup as follows MV/var/lock/subsys/mysqld/var/lock/subsys/mysqld_ bakkillall mysqld

Rerun: Service mysqld start
found to work normally

==================================================================

Note: when it comes to deletion, we should carefully consider the operation!

==================================================================

Server failed during MySQL installation or re installation

Today, an error occurred when re installing MySQL service,
the action ‘install’ for product ‘MySQL server 5.7.19’ failed

1: Action 14:02:10: INSTALL. 
1: 1: MySQL Server 5.7 2: {EC09D203-422B-4C9F-B623-230EF57EE709} 
1: Action 14:02:10: FindRelatedProducts. Searching for related applications
1: Action 14:02:10: AppSearch. Searching for installed applications
1: Action 14:02:10: LaunchConditions. Evaluating launch conditions
1: This application requires Visual Studio 2013 Redistributable. Please install the Redistributable then run this installer again.
1: 1: MySQL Server 5.7 2: {EC09D203-422B-4C9F-B623-230EF57EE709} 3: 3 
1: The action 'Install' for product 'MySQL Server 5.7.19' failed.

That is, the database server was not installed successfully
at first, I thought that the previous MySQL was not unloaded completely. I also found many ways on the Internet, but they couldn’t work. Later, I tried many times and found a way in a post.

It’s Keng, it’s Si, it’s Le
you need to upgrade a plug-in, Visual C + + 2013 and Visual C + + redistributable packages
and use 32-bit Visual C + + redistributable packages for visual studio 2013!!! Note that it’s 32-bit. Even if your computer is 64 bit

Installation website: https://www.microsoft.com/zh-cn/download/details.aspx?id=40784
Click download and select
vcredist_ X86.exe-6.2 MB
download and install
after installation, the database server can be installed successfully.


If you think it’s helpful, remember to praise and encourage~

Scan the QR code above to follow my subscription number~

Error occurred when Android connected to cloud MySQL: java.lang.NoClassDefFoundError : Failed resolution of: Ljava/sql/SQLType

The error information is as follows:

E/AndroidRuntime: FATAL EXCEPTION: Thread-4
    Process: com.example.NCEPU, PID: 19597
    java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
        at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:746)
        at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1170)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
        at java.sql.DriverManager.getConnection(DriverManager.java:580)
        at java.sql.DriverManager.getConnection(DriverManager.java:218)
        at com.example.NCEPU.Utils.MySQLUtil$1.run(MySQLUtil.java:20)
        at java.lang.Thread.run(Thread.java:929)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[zip file "/data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/lib/arm64, /data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /hw_product/lib64, /system/product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:746) 
        at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1170) 
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447) 
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) 
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) 
        at java.sql.DriverManager.getConnection(DriverManager.java:580) 
        at java.sql.DriverManager.getConnection(DriverManager.java:218) 
        at com.example.NCEPU.Utils.MySQLUtil$1.run(MySQLUtil.java:20) 
        at java.lang.Thread.run(Thread.java:929) 
W/libEGL: EGLNativeWindowType 0x6f3882b950 disconnect failed
I/Process: Sending signal. PID: 19597 SIG: 9

Problem analysis: the jar package version of MySQL is too high</ Font> I originally used the latest version: mysql-connector-java-8.0.21.jar

Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://your ip:port/dbname?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
connection = DriverManager.getConnection(url, user, password);

Problem solving: the jar version is a little lower. Here I use mysql-connector-java-5.1.49.jar downloaded from the official website. Note that after changing to the lower version, the loading driver should change to:

Class.forName("com.mysql.jdbc.Driver");

MySQL: invisible empty symbol char (9) char (10) char (13)

When counting annual sales, I always feel that something is wrong. So I looked for it, right, tried trim, eliminated the spaces before and after, and didn’t respond.

On the verge of collapse, the cause of the mistake was finally discovered.

When I entered, I pasted many other blank symbols. I couldn’t see them or touch them. Ah~

Finally: update SKU_ pure set FBASKU = replace(replace(replace(FBASKU,char(9),”),char(10),”),char(13),”);

End

Another example:
Update SKU_ pure_ Copy1 set fbasku = replace (replace (replace ( fbasku , char (9), ‘), char (10),’), char (13), ‘, store = replace (replace ( store , char (9),’), char (10), ‘), char (13),’), SKU = replace (replace ( SKU , char (9), ‘), char (10),’), char (13), ‘)

If you encounter these hidden blank symbols, don’t be afraid to use the following sentence to solve them in one step:

update table_ name
set column_ name = replace(replace(replace(column_ name,char(9),”),char(10),”),char(13),”);

Description: table_ Name: table name column_ Name: column name, field name, variable name

Char (9), char (10) and char (13) are:
char (9) represents the horizontal tab (TAB key)

Char (10) denotes the newline key (\ n)

Char (13) indicates enter (
)

Org.yaml.snakeyaml.parser.ParserException: while parsing a block mapping

org.yaml.snakeyaml.parser.ParserException: while parsing a block mapping

Reason: yml file format error, this file requires strict requirements format

If the nodes are not aligned, align the Mybatis nodes with the Spring nodes, here is the yml configuration file for SpringBoot 2.0 + Mybatis + Mysql

server:
port: 8080
spring:
datasource:
name: daducha
type: com.alibaba.druid.pool.DruidDataSource
druid:
url: jdbc:mysql://127.0.0.1:3306/daducha
username: root
password: root
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
driver-class-name: com.mysql.jdbc.Driver
mybatis:
mapper-locations: classpath:mapping/*.xml
type-aliases-package: com.wuji.entity.po

When laravel is uploaded to the server, whoops, looks like something went wrong appears

1. When laravel, which can run well locally, uploads to the server, this problem appears: “whoops, looks like something wet wrong.”

2. Step one/ app.php ‘debug ‘= &> env (‘app’) in file_ Debug ‘, false), change to’ debug ‘= &> env (‘app’)_ DEBUG’, true),

3. A lot of information is displayed now

We notice that no supported encryption found.The Cipher and/or key length are invalid_ Copy the key value and modify it/ app.php Inside

‘key’ =&> env(‘APP_ KEY’,’base64:R+8tyPpcbK6ELMheXa4D8hsxdVvXDilVUSFCFqaH8vY=’),

This app_ Key can also be accessed through PHP artisan key:generate Generation

Now report another mistake

The description here is database connection error, modify config/ database.php File database connection problem ‘MySQL’ = & gt[

‘driver’ =&> ‘mysql’,

‘host’ =&> env(‘DB_ HOST’, ‘localhost’),

‘port’ =&> env(‘DB_ PORT’, ‘3306’),

‘database’ =&> env(‘DB_ DATABASE’, ‘forge’),

‘username’ =&> env(‘DB_ USERNAME’, ‘forge’),

‘password’ =&> env(‘DB_ PASSWORD’, ”),

‘charset’ =&> ‘utf8’,

‘collation’ =&> ‘utf8_ unicode_ ci’,

‘prefix’ =&> ‘pty_ ‘,

‘strict’ =&> false,

‘engine’ =&> null,

],

Modify the corresponding database configuration

5. There is no problem when logging in to the background administrator, but an error is reported when logging in to the added administrator

This problem is a cache problem. Modify the config/ cache.php File, put ‘default’ = &> env (‘cache ‘)_ Driver ‘,’File’), change to

‘default’ =&> env(‘CACHE_ DRIVER’, ‘array’),

This is because this error occurred when adding roles using the zizaco/enter permission package.

Need to communicate with small partners can click here to add my QQ: Luke

You can’t specify target table for update….

This article mainly introduces the MySQL you can’t specify target table for update in from clause error resolution, need friends can refer to

The error of you can’t specify target table for update in from clause in MySQL means that you can’t select some values in the same table and then update the table (in the same statement). For example, the following SQL:

delete from tbl where id in 
(
        select max(id) from tbl a where EXISTS
        (
            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)&>1
        )
        group by tac
)

Just rewrite it as follows:

delete from tbl where id in 
(
    select a.id from 
    (
        select max(id) id from tbl a where EXISTS
        (
            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)&>1
        )
        group by tac
    ) a
)

That is to say, select the result through the middle table again, so as to avoid the error. Note that this problem only occurs in mysql, and will not occur in MSSQL and Oracle.

MYSQL: You must reset your password using ALTER USER statement before executing this statement.[How to Solve]

1. Problem: after logging into mysql, no matter what command you run, you will always prompt this

mysql&> select user,authentication from mysql.user;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql&> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

2. Solutions

The solution is as follows.

(1) MySQL version 5.7.6 (previous) users can use the following command.
        mysql&> SET PASSWORD = PASSWORD('l!vWT#mL93');
 
(2) Users of MySQL version 5.7.6 (after the start) can use the following command.
        mysql&> ALTER USER USER() IDENTIFIED BY 'l!vWT#mL93';
     

3. Cause analysis

(1) MySQL version 5.6.6 onwards adds the password_expired feature, which allows setting a user's expiration time. This feature has been added to the mysql.user data table, but its default value is "N", which can be changed using the ALTER USER statement.
  Enter the following command to force the account password to expire.
  mysql&> ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
  At this point, the user can log in to the MYSQL server, but cannot run any commands until the user sets a new password for the account, and will get the above error, and can run all commands within the account permissions normally by changing the password. Since the password expiration days cannot be achieved by command in this version, the DBA can set the password expiration time for MySQL users by cron timer task.

(2) Starting from MySQL version 5.7.4, the feature of password expiration time for users has been improved, and a global variable default_password_lifetime can be used to set the password expiration policy, and this global variable can set a global automatic password expiration policy. A default value can be set in MySQL's my.cnf configuration file.
  (a) This will cause all MySQL users to have a password expiration time of 120 days, and MySQL will start counting the time from startup.
    The my.cnf configuration is as follows.
    [mysqld]
    default_password_lifetime=120
  (b) If you want to set the password to never expire, my.cnf is configured as follows.
    my.cnf is configured as follows.
    [mysqld]
    default_password_lifetime=0
(3) If you want to set individual specific values for each specific user account, you can use the following command (note: this command will override the global policy) in "days", the command is as follows.
  ALTER USER 'root'@'localhost' PASSWORD EXPIRE INTERVAL 250 DAY;

(4) If you want the user to restore the default policy, the command is as follows.
  ALTER USER 'root'@'localhost' PASSWORD EXPIRE DEFAULT;
(5) Individual users will disable the password expiration function for late trouble, the command is as follows.
  ALTER USER 'testuser'@'localhost' PASSWORD EXPIRE NEVER;