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

How to install jdk and mysql on centos

王林
王林forward
2023-05-26 15:35:071326browse

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

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值

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

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

Restart the mysql service after successful installation.

# service mysqld restart

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>

Five: Configure mysql

1, encoding

The mysql configuration file is /etc/my.cnf

Finally add the encoding configuration

[mysql]
default-character-set =utf8

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';

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

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

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete