Home  >  Article  >  Database  >  Build mysql server on linux system

Build mysql server on linux system

王林
王林forward
2020-06-10 09:28:322738browse

Build mysql server on linux system

1. Download the mysql installation package from the official website

The following picture is an introduction to the mysql installation package

Build mysql server on linux system

2 , Install software package

1, Install dependencies

# yum -y install perl-Date-Dumper perl-JSON perl-Time-HiRes

2, Unzip the mysql installation package

# tar -xvf mysql-5.7.24.tar               //解压mysql包

3, Uninstall the old version of the package

[root@localhost ~]# rm -rf /etc/my.cnf

4, Delete data

[root@localhost ~]# rm -rf /var/lib/mysql/*

5. Uninstall the software package (no software package will be displayed as uninstalled)

[root@localhost ~]# rpm -e --nodeps mariadb-server mariadb

Warning: /var/log/mariadb/mariadb.log has been saved as /var /log/mariadb/mariadb.log.rpmsave

#yum -y remove mariadb-libs.x86_64 1:5.5.52-1.el7

6. Install yum source

#yum -y install mysql-community-client mysql-community-common mysql-community-devel mysql-community-embedded mysql-community-embedded-compat mysql-community-embedded-devel  mysql-community-libs mysql-community-libs-compat mysql-community-minimal-debuginfo mysql-community-server mysql-community-test

or

#yum -y install mysql-community-*.rpm

7. Check the installed mysql related installation package

# rpm -qa | grep -y mysql

8. Start the service

# systemctl start mysqld
# systemctl enable mysqld //设置开机自启
# systemctl status mysqld
[root@proxy mysql]# ss -antulp | grep mysqld //查看服务启动端口
# ps aux | grep mysqld //查进程

3. Connect to the database

1. Check the randomly generated root password

# grep password /var/log/mysqld.log
#  grep 'temporary password' /var/log/mysqld.log //随机生成的管理密码

Initial password login mysql:

(!!!You must change the password management immediately when logging in with a randomly generated password, otherwise an error will be reported)

2. Client command mysql to connect to the database

# mysql -hlocalhost -uroot -p'pIhMu,i2OS#,' //用初始密码登录
mysql> \h //登录成功后,查可用的快捷键

4. Change the password

1. You can only modify the password first

mysql> alter user root@"localhost" identified by "123qqq...A";

2. You can modify the password limit length

mysql> show variables like "%password%";              //查询密码有关的变量
mysql> set global validate_password_policy=0;       //只验证长度
mysql> set global validate_password_length=6;      //修改密码长度为6位
mysql> alter user root@"localhost" identified by "123456";             //修改root密码为123456

Recommended tutorial: mysql tutorial

The above is the detailed content of Build mysql server on linux system. For more information, please follow other related articles on the PHP Chinese website!

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