Tag Archives: mysql

[Solved]Error 1054 (42s22): unknown column ‘password’ in ‘field list’ how to modify the password

1. Update list apt get

sudo apt-get update

2. Install MySQL server and client

sudo apt-get install mysql-server mysql-client

3. When installing the server, if there is no default password, there is no password. Enter the following command to enter mysql

mysql -u root -p

4. Modify the root password. Note that the password field does not exist and needs to be modified to authentication_ String to modify

use mysql;
update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password"; 
flush privileges;
quit;

5. Set the encoding, modify the/etc/MySQL/my.cnf file, and add the following contents:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8

6. Enter Mysql to view the status (whether the code is utf8)

status or \s

7. Start and close MySQL service

open:service mysql start
close:service mysql stop
restart:service mysql restart

Qt development, using ODBC interface, query mysql, appear qsqlquery:: Value: not positioned on a valid record

Qt development, using ODBC interface, query mysql, appear qsqlquery:: Value: not positioned on a valid record

Question: in the library management system developed by QT craetor integrated development environment, the newly created database class is used to operate the database. It inherits from QObject and uses the interface provided by ODBC to connect with the database. The database is mysql5.7, When using the following query statement, we report an error:

error information: qsqlquery:: Value: not positioned on a valid record

we query the relevant information:
the solutions we have found
try according to the solutions provided in the article, the problems still exist.

Later, some information was printed in various locations, and it was found that qdebug & lt& lt; condition<& lt; content<& lt;“ The variables condition and content in “on” can be printed normally, but “on” printed out is “?”
when I thought of creating a window before, the window title set in Chinese would be garbled. The solution I found at that time was to add the following code to the. Cpp file of the corresponding class:
?Pragma execution_ character_ set("utf-8")

Solution:
add the code block as shown above to the database.cpp file:

edit test information:

test output successful:

end! Scatter flowers! Record it!

Navicat for MySQL error 1251 failed to connect to MySQL

It’s very useful to have a try, so make a record of it https://blog.csdn.net/wshxhghsjjsn/article/details/80459542


As like as two peas, I wrote the previous revision, but my MySQL version was 8. The current version is 5.7. So the screenshots are weird, but the steps are the same. I have tried all the 2 versions.

Step one: open as like as two peas, Command Line Client, see CMD, mysql, and you will find 2 identical ones.

Step 2: enter the password of MySQL. Enter is the password set when installing mysql. Only enter the password without semicolon

Step 3: enter alter user ‘root’ @’localhost ‘identified with MySQL_ native_ Password by ‘MySQL password’; Don’t miss the carriage return. There is a semicolon at the back. The password of MySQL is set when installing mysql

Step 4: input flush priorities; Don’t miss the semicolon at the back of the carriage return

Let me demonstrate: my MySQL password is 111111

The word “OK” won’t make a mistake

You can also modify the MySQL password through this method. For example, my MySQL password is 111111, I want to change it to 123456

That is to change the password of Mysql to 123456

[Solved] The number of rows returned by the mybatis UPDATE statement is always 1 or useaffectedrows = true

The number of rows returned by the mybatis UPDATE statement is always 1 or useaffectedrows = true

Problem solving explanation useaffectedrows = true

solve the problem

     This is because the database url connection is missing useAffectedRows=true

 The problem is solved here, but I'll explain it later useAffectedRows=true.

Explain useaffectedrows = true

 useAffectedRows defaults to false, and the value returned is the number of rows matched.
    useAffectedRows = true, the value returned is the number of rows affected.

[Solved] There is a problem with mysql8.0 without password in Navicat connection

There is a problem with mysql8.0 without password in Navicat connection

**Problem: * * connect to mysql8.0 with Navicat, but the test connection fails
* * reason: * * when installing mysql8.0, there is no password set, and there is no random password under data in the MySQL installation directory

Solutions:
1. Stop the MySQL service
open the CMD as an administrator and close it or close the windows service page

C:\Users\xxx>net stop mysql`

2. As an administrator, open the CMD page and enter the following command to start MySQL without password

C:\Users\xxx>mysqld --console --skip-grant-tables --shared-memory

Take a look at the following screen:

3. Open a new CMD page and enter the following statement:

mysql> flush privileges; -- Modify Permissions
Query OK, 0 rows affected (0.16 sec)
 
mysql> ALTER USER "root"@"localhost" IDENTIFIED BY "123456"; -- Modify Password
Query OK, 0 rows affected (0.08 sec)

Then the login password is 123456

4. After setting, start the MySQL service normally, and use the user name and password to verify whether the setting is successful

Problems in connecting mysql8.0 in IDEA [How to Solve]

MySQL 5.7 has always been used before, because some changes have taken place after updating to MySQL 8.0, and some information needs to be modified in the configuration of MySQL driver connection.

In MySQL version 5.7, getting the database connection is realized by the following code

connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/数据库名称","数据库账号","数据库密码");

In MySQL 8.0, you need to add a time zone. The implementation code is as follows

connection = DriverManager.getConnection(” jdbc:mysql :// localhost:3306/ Database name true & amp; characterEncoding=utf-8&& amp; serverTimezone=GMT%2B8& Usessl = false “,” database account “,” database password “);

After completing the above modification, you can perfectly solve the connection problem of mysql8.0. The connection is successful, as shown in the figure below

Local can link to the server database, upload jar package to the server will report an error

Question:

The problem encountered in the project is very strange. MySQL database is installed on CentOS, and the project is spring boot.

When the project is started locally, it is normal to connect to the server database, the local database client is normal to connect to the server database, and the server is normal to connect to the client database. When the project is deployed to the server, an exception is thrown.

A lot of misinformation..

The most important thing is:

java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)

reason:

I forgot to repack every time you run a project, idea will not help you repackage it. You need to do it yourself

Other questions can be referred to

https://www.cnblogs.com/secbro/p/12544158.html

Navicat import local SQL file error “[MSG] finished – unsuccessfully | [err] 1046 – no database selected”

Error screen:

reason:

If you do not create a database with the same name and character set, you can directly right-click run SQL file on MySQL

 
solve:

1. Create a database with the same name and character set under MySQL

2. Under the newly created database, right-click run SQL file

3. Deselect the second item

4. Click start to import SQL file successfully

The problem has been solved. If the table has not been loaded, refresh the navicate or exit and reopen it

TypeError: connection.connect is not a function

Today, when I wrote node.js to operate the database, I encountered a typeerror: connection.connect is not a function when setting up the database connection. The following is the bug prompt, as shown in the figure

when I found this error, I immediately went to connection.connect, but I didn’t find anything wrong,
For this reason, I made a special effort to find the previous code and compare it. The following is the thinking at that time

later, I asked my friend to check the custom module
PS: after staring at it for more than ten minutes, I didn’t find the error. At this moment, I felt like a mentally retarded person

later, I had to check one by one, I found that my mistake was to write the return value of the function as an object….. Verification complete….. Retarded stone hammer…..

Change it to the following way

rerun