Detailed explanation of linux installation of mysql database and configuration of Java project
First, install mysql database
① downloads and unzips and uploads to the / opt/soft directory (the soft directory is self-created)
② decompression: tar-xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
③ empties the database that comes with linux
1. Check to see if there is an older version of the database:
Rpm-qa | grep mysql
Rpm-qa | grep mariadb
two。 Uninstall the existing database: (uninstalling will uninstall the dependent packages of this package as well)
Yum-y remove mariadb-libs.x86_64
④ installs the mysql Community Edition service pack:
Rpm-ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
It is found that 5 dependency packages are needed, so install the dependency packages first (needed dependencies)
1. Install the dependency package for perl:
Yum-y install perl (there are 27 packages with perl installed here, including 3 dependent packages)
two。 Install the dependency package for mysql-community-client:
Rpm-ivf mysql-community-client-5.7.27-1.el7.x86_64.rpm
Find that this package depends on: mysql-community-libs, so install the mysql-community-libs package first.
Install the mysql-community-libs library package:
Rpm-ivf mysql-community-libs-5.7.27-1.el7.x86_64.rpm
3. Reinstall mysql-community-cient-5.7.27-1.el7.x86_64.rpm
4. Install the dependency package for mysql-community-common:
Rpm-ivf mysql-community-common-5.7.27-1.el7.x86_64.rpm
⑤ install the mysql Community Edition server package again:
Rpm-ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
⑥ verifies whether mysql is installed successfully (startup does not report an error means installation is successful)
Start the mysql service: systemctl start mysqld.service
Find the temporary password and change it
① looks for the file where the temporary password is stored:
Find /-name mysql*log
② view temporary password:
More / var/log/mysql.log | grep temp
(password is C_XMoVU7jjcW)
③ enter mysql-u root-p and temporary password to log in to enter the environment of mysql database
④ in the environment of mysql database:
1. Set the mysql password policy:
Mysql > set global validate_password_policy=0
two。 Set the length of the mysql password:
Mysql > set global validate_password_length=4
3. Set the password:
Mysql > set password=password ('123456')
4. Exit: quit; or ctrl+z
View and create remotely connected users
① checks to see if users can connect remotely:
1. Login: mysql-u root-p; enter password to log in (123456)
two。 Enter: use mysql
3. Viewing: select host,user,authentication_string from user
② creates a remote user
1. Create user: create user 'myroot'@'%' identified by' 123456'
two。 Permission granted: grant all privileges on *. * to 'myroot'@'%'
3. Refresh: flush privileges
Use the Navicat tool to log in remotely
① turns off the firewall: systemctl stop firewalld.service
② to connect
③ connected successfully
Configure the java project
The project contains: package (.war) + package (.sql)
① uploads .war and packages to the wbapps directory under tomcat (in the / opt/soft/apach-tomcat-8.5.47 directory)
② imports the .sql packet into Navicat (after connecting, left-click, and then click to run the SQL file)
③ starts the tomcat service: (to start under the bin directory under the apache-tomcat-8.5.47 directory)
Sh startup.sh
④ modifies the file in which the project connects to the database so that the project connects to the database
Default path: (automatically decompress the project after uploading, refresh it first)
/ opt/sotp/apache-tomcat-8.5.47/webapps/test/WEB-INF/classes
Modify:
1. Ip address of database service: (change to ip address of linux)
two。 Database name: (change to project database name)
3. User name of the remote connection user: (user name myroot)
4. Password of remote connection user: (password of user myroot)
5. Save
⑥ turn off the firewall:
Systemctl stop firewalld.service
⑦ open web page: enter 192.168.1.181:8080/test
⑧ input user name and password to test login
⑨ login
These are all the knowledge points of linux installation mysql configuration Java introduced in this paper. Thank you for your study and support.