current position:Home>Connect to database mysql

Connect to database mysql

2022-01-27 00:43:07 Fat gaga I

First check whether the system has been installed MySQL
command :

rpm -qa|grep mariadb


If appear mariadb-libs-5.5.56-2.el7.x86_64 file , Then unload it  
command :

rpm -e --nodeps  mariadb-libs-5.5.56-2.el7.x86_64


If you do not uninstall the above files , Will not be found in later operations MySQL Folder
take MySQL Extract the installation package to /opt/module/ In the folder

command :

cd /opt/software/tar -xf  The name of the file to unzip  -C /opt/module

Upload it to linux Next /opt/software in

One 、 Decompress it to /opt/module Next

The order is :

 tar -xf  Files to extract  -C  Where to unzip 

Two 、 Install the corresponding rpm file

1. Get plug-ins :

command :

yum install -y libaio

2. Carry out orders :

sudo rpm -ivh --nodeps mysql-community-common-5.7.36-1.el7.x86_64.rpm

sudo rpm -ivh --nodeps mysql-community-libs-5.7.36-1.el7.x86_64.rpm

sudo rpm -ivh --nodeps mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm

sudo rpm -ivh --nodeps mysql-community-client-5.7.36-1.el7.x86_64.rpm

sudo rpm -ivh --nodeps mysql-community-server-5.7.36-1.el7.x86_64.rpm

3、 ... and 、 Switch to etc

Four 、cat my.cnf

5、 ... and 、 Switch to /var/lib/mysql, And delete all files  rm -rf  

6、 ... and 、 Reset mysql:

mysqld --initialize --user=mysql

7、 ... and 、 View the generated random password :

command :

cat /var/log/mysqld.log

8、 ... and 、 start-up MySQL service

command :

systemctl start mysqld

Sign in MySQL/ database

mysql -uroot -p

Enter password:   Enter the temporarily generated password

   Login successful .

Must be modified first root User's password , Otherwise, an error will be reported when performing other operations

mysql> set password = password(" New password ");

modify mysql Under the Treasury user In the table root The user allows any ip Connect

mysql> update mysql.user set host='%' where user='root';

mysql> flush privileges;

copyright notice
author[Fat gaga I],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270043060654.html

Random recommended