Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to install mysql on Linux server

Shulou Source: shulou.com Published: 2022-06-01 12:48:46 09月14日 Update

This article mainly explains "how to install mysql on Linux server". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install mysql on Linux server.

Install mysql

1. Check whether mysql is installed

[root@localhost bin] # rpm-qa | grep mysql

Mysql-libs-5.1.71-1.el6.i686

[root@localhost bin]

2. Install mysql and mysql-server

[root@localhost bin] # yum install-y mysql

[root@localhost bin] # yum install-y mysql-server

3. Start mysql and notice that the name of the service here is "mysqld"

[root@localhost bin] # service mysqld start

Shell-init: error retrieving current directory: getcwd: cannot access parent directories: there is no such file or directory

Chdir: error retrieving current directory: getcwd: cannot access parent directories: there is no such file or directory

Initialize the MySQL database: Installing MySQL system tables...

OK

Filling help tables...

OK [OK]

Starting mysqld: [OK]

[root@localhost bin] #

4. Configure MySQL to boot

[root@localhost bin] # chkconfig mysqld on

[root@localhost bin] # chkconfig-- list mysqld

Mysqld 0: off 1: off 2: enable 3: enable 4: enable 5: enable 6: close

[root@localhost bin] #

5. Set the root user password. The command to set the password is "mysqladmin-u username password password".

[root@localhost bin] # mysqladmin-u root password 543092 / / password is 543092

6. Change the password. The command is "mysqladmin-u user name-p password new password".

[root@localhost bin] # mysqladmin-u root-p password 123456 / / New password 123456

Enter password: / / the old password is required here

[root@localhost bin] #

7. Mysql configuration file "/ etc/my.cnf"

[root@localhost bin] # cat / etc/my.cnf

[mysqld]

Datadir=/var/lib/mysql / / database file directory

Socket=/var/lib/mysql/mysql.sock / / socket file

User=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

Symbolic-links=0

[mysqld_safe]

Log-error=/var/log/mysqld.log / / log file

Pid-file=/var/run/mysqld/mysqld.pid / / process pid file

8. Modify the port

1) the default port of mysql is 3306, which can be viewed using netstat

[root@localhost bin] # netstat-tunlp | grep mysqld

Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN 4339/mysqld

2) modify the port in the configuration file, open the configuration file, and append the word "port=xxx" after it.

[root@localhost bin] # gedit / etc/my.cnf

Port=3307

3) restart the myslqd service to view the port

[root@localhost bin] # service mysqld restart

Shell-init: error retrieving current directory: getcwd: cannot access parent directories: there is no such file or directory

Chdir: error retrieving current directory: getcwd: cannot access parent directories: there is no such file or directory

^ [A stop mysqld: [OK]

Starting mysqld: [OK]

[root@localhost bin] # netstat-tunlp | grep mysqld

Tcp 0 0 0.0.0.0 3307 0.0.0.015 * LISTEN 4604/mysqld

At this point, I believe you have a deeper understanding of "Linux server how to install mysql", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: File password service directory port configuration server user content command data database being user name new secret learning practical deeper one word interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux macOS Huawei Microsoft OPPO Reno