The article directories

  • preface
  • Installation steps
  • conclusion

preface

This article takes you through installing MySQL on Linux


Installation steps

1, download MySQL version of CentOS dev.mysql.com/downloads/m…

2. Upload the file to the /usr/local directory

3. Unzip the files

The tar XVF mysql - 8.0.12 - Linux - glibc2.12 - x86_64. Tar. XzCopy the code

4. The decompressed directory name is too long. Rename the directory to mysql

Mysql - mv 8.0.12 - Linux - glibc2.12 - x86_64 mysqlCopy the code

Create data directory in mysql

cd mysql
mkdir data
Copy the code

6. Create a mysql user group and a mysql user

groupadd mysql
useradd -g mysql mysql
Copy the code

Change mysql directory permissions

chown -R mysql.mysql /usr/local/mysql/
Copy the code

Initialize the database

2) initialize bin/mysqld --initialize --user= mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/dataCopy the code

After successful initialization, record your original password:



9. Configure MySQL

Open the Mysql configuration file

vi /etc/my.cnf
Copy the code

Add content:

[mysqld]
basedir=/usr/local/mysql 
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
character-set-server=utf8
port=3306
[mysql]
socket=/usr/local/mysql/mysql.sock
port=3306
Copy the code

Exit, save

esc
:wq
Copy the code

Create MySQL server

2) add chmod +x /etc/init.d/mysql 3) to add the service file to the system service Chkconfig --add mysql 4) check service chkconfig --list mysqlCopy the code

11. Configure global environment variables

1) Open the configuration file vi /etc/profile 2) Add the following information at the bottom of the configuration file: The export PATH = $PATH: / usr/local/mysql/bin: / usr/local/mysql/lib export PATH 3) make the effective source file/etc/profileCopy the code

12. Start the service

service mysql start
Copy the code

The user name for logging in to MySQL is root, and the password is initialized

Mysql -uroot -p Enter the passwordCopy the code

14. Log in to the MySQL database and change the password

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password ';Copy the code

or

Set password for root@localhost = password(' new password ');Copy the code

conclusion

Now that we have the JDK, Tomcat, and MySQL installed, we are ready to deploy a simple Java project on Linux.