Home > Database > Mysql Tutorial > How to install jdk and mysql on centos

How to install jdk and mysql on centos

王林
Release: 2023-05-26 15:35:07
forward
1320 people have browsed it

1: Environment

How to install jdk and mysql on centos

2: Download the jdk rpm package locally and upload it to the server (because of this I just started using wget to download directly to the server, and the installation kept reporting errors, so I decided to use this stupid method)

Download address:

How to install jdk and mysql on centos

jdk is installed by default In /usr/java

How to install jdk and mysql on centos

Three: Configure environment variables

My machine has installed jdk-8u151-linux-x64 After .rpm, the java –version operation can be performed normally without configuring environment variables, so I did not configure the jdk environment variables. But for the sake of future discomfort, here is a record of how to configure it. The operation is as follows:

Modify the system environment variable file

vi  /etc/profile
Copy after login

Append the following content to the file:

java_home=/usr/java/jdk1.8.0_151

jre_home=/usr/java/jdk1.8.0_151/jre

path=$path:$java_home/bin:$ jre_home/bin

classpath=.:$java_home/lib/dt.jar:$java_home/lib/tools.jar:$jre_home/libexport java_home jre_home path classpath

Make the modification effective

[root@localhost ~]# source /etc/profile  //使修改立即生效
[root@localhost ~]#echo $path  //查看path值
Copy after login

Check the system environment status

[root@localhost ~]# echo $path
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/bin:/usr/java/jdk1.8.0_25/jre/bin
Copy after login

Four: Install mysql (download and install mysql-server from the official website)

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
Copy after login

Restart the mysql service after successful installation.

# service mysqld restart
Copy after login

When installing mysql for the first time, the root account does not have a password.

Set password

mysql> set password for 'root'@'localhost' =password('password');
query ok, 0 rows affected (0.00 sec)
mysql>
Copy after login

Five: Configure mysql

1, encoding

The mysql configuration file is /etc/my.cnf

Finally add the encoding configuration

[mysql]
default-character-set =utf8
Copy after login

The character encoding here must be consistent with /usr/share/mysql/charsets/index.xml.

2. Remote connection settings

Assign all permissions of all tables in all databases to the root user located at all IP addresses.

mysql> grant all privileges on *.* to root@'%'identified by 'password';
Copy after login

If it is a new user instead of root, you must first create a new user

mysql>create user 'username'@'%' identified by 'password';
Copy after login

Then you can connect remotely.

The above is the detailed content of How to install jdk and mysql on centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template