In Linux, configuring MySQL Databases on Tomcat is not as simple as windows... Therefore, it is worth writing down a record for future reference.
1. Download and install MySQL
Installing MySql in Ubuntu is very simple. You only need:
Sudo apt-Get install mysql-Server
During the installation process, you will be asked to set the user name and password. Mine is root and root.
2. Download JDBC
Go to http://www.mysql.com/downloads/download MySQL connectors for Java
Decompress the package and place the mysql-connector-java-5.1.24-bin.jar in the % atat_home/lib directory.
3. Configure Tomcat
Open the % atat_home/CONF/context. xml file,
Add the followingCode:
<Resource Name = "JDBC/mysqlds" auth = "Container" type = "javax. SQL. datasource "maxidle =" 30 "maxwait =" 3000 "maxactive =" 10 "username =" root "Password =" root "driverclassname =" org. gjt. mm. mySQL. driver "url =" JDBC: mysql: // localhost/LC "> </resource>
Note that username and password are set to the value set during MySQL installation.
Then you can use JSP code to perform database operations.
However, there is still a problem, that is, when we operate MySQL on the terminal, the error "MySQL access denied for user" will be reported.
The solution is to enter:
Sudo mysql-uroot-P
Then enter the password of the root user to access the MySQL database.