Java notes --- Mysql errors

Source: Internet
Author: User

Java notes --- Mysql errors
1. 'mysql' is not an internal or external command, nor a program or batch processing file that can be run.

Scenario

Remotely log on to mysql in cmd on a Windows Server

Error cause

Mysql configuration is not added to the environment variable Path on the local machine.

Troubleshooting

Configure Environment Variables
① New variable MYSQL-HOME

② Include MYSQL-HOME In Path

Result: a Dos test is performed on the local host.

Remote logon again:

2. ERROR 1130: Host 'xxx' is not allowed to connect to this MySQL server

Scenario

Remotely log on to mysql from a local machine

Error cause

The remote login permission is not granted to the user on the remote server.

Troubleshooting

On the remote machine, mysql grants the remote logon permission to execute commands.Grant all privileges on.To 'root' @ '%' identified by 'root' with grant option;

Command details: # grant all permissions to the root user and allow them to remotely log on to grant all privileges on *. * to 'root' @ '%' identified by 'root' with grant option; parameter explanation: ① all privileges: grant all permissions to the specified user, you can also replace it with a specific permission (2 *. *: the permissions granted are for all tables of all databases. If a specific table of a specific database is specified, for example, thinkphp_user ③ root: Indicates authorizing the root user ④ '%': indicates that the connected IP address is not limited. If you want to allow remote logon from only a specific IP address, you can change it to a specific IP address. ⑤ By 'root': password of the root user
Java. lang. ClassNotFoundException: com. mysql. jdbc. Driver xxx

Scenario

Use a Java program in CenOS to connect to the mysql database and obtain records in the database.

Error cause

Mysql driver jar not found

Troubleshooting

View the current mysql version and copy the mysql driver jar to the installation directory of Java using the cp command, that is/usr/lib/jvm/java-1.xxx/jre/lib/ext/, so that the Java program to find the mysql driver jar

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

Scenario

Use a Java program to connect to the mysql database and obtain records in the database

Error cause

Possible causes
1. Incorrect password
2. Use the root user to connect. in Linux, the root user does not need a password by default.

Troubleshooting

Make changes based on the reason. I leave the password empty because I use root.

V. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)

Scenario

To solve the problem of mysql garbled, directly modified the mysql my-medium.cnf, resulting in configuration file error, unable to find the mysql. sock file, startup failed

Error cause

Mysql startup failed, no mysql. sock file is generated

Troubleshooting

Restoring the configuration file does not work. Uninstall and reinstall mysql. View the mysql Error Log and find the error:Error: Can't open and lock privilege tables: Table 'mysql. user' doesn' t exist.

The problem occurs in the mysql table. Solution: reinitialize mysql. Run the following command:Mysql_install_db-usrer = mysql <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Vc3Ryb25nPjxiciAvPg0KPGltZyBhbHQ9 "mysql-error5" src = "http://www.bkjia.com/uploads/allimg/160403/0412123Y8-9.jpg" title = "\"/>
In this way, start mysql again and run Service mysqld restartOK

6. MySQL Daemon failed to start.

The situation is the same as ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)

7. Error: Can't open and lock privilege tables: Table 'mysql. user' doesn' t exist

The situation is the same as ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)

8. ERROR 1064 (42000): You have an error in you SQL syntax; check the manual that the right syntax to use near 'database' at line 1

Scenario

Execute the SQL file. The database in the SQL file is thinkphp, which contains a user table with records

Error cause

Currently, mysql does not have the thinkphp database.

Troubleshooting

Execute CommandCreate database thinkphpCreate the thinkphp database and then executeUse thinkphpCommand, and then execute the SQL file.

9. ERROR 1005 (HY000): Can't create table 'mysql. user', ERROR 1146 (420S02): Table 'mysql. user' doesn' t exist

Scenario

Execute the SQL file. The database in the SQL file is thinkphp, which contains a user table with records

Error cause

Currently, the mysql database is used instead of the thinkphp database, and therefore cannot be executed.

Troubleshooting

Switch to the thinkphp Database: run the use thinkphp command and run the SQL file again.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.